Hello.
I was wondering why we did not cache Game Status when we cached Level.
I know each cache just adds weight and becomes taxing for the computer in the long run, but I am unsure about the logic behind it.
Could someone explain it to me please?
Hello.
I was wondering why we did not cache Game Status when we cached Level.
I know each cache just adds weight and becomes taxing for the computer in the long run, but I am unsure about the logic behind it.
Could someone explain it to me please?
Hey SaloXtreme,
At the bottom of every video on Udemy there’s question mark in a circle that looks something like this --> (?). That is the Udemy Q&A board. You can check there if anybody else asked that question before! I gave it a quick check and found the following explanation by Nina:
At the moment, we destroy the block game object when it gets hit by the ball. For this reason, we do not have to cache GameStatus because we use it one time only.
If the block had multiple lives, caching the reference would be recommended if we want to call AddToScore multiple times.
Further down Jason replies with:
I also had the same question, during the challenge, i cached GameStatus as gameStatus and used the find object of type in the start method… it did work, so i guess multiple ways of doing everything
That means, yes, both ways work fine! I believe the logic behind it is to get used to programming in a way that uses minimum system resources. Your Block Breaker game may be small, so you won’t notice the performance impact. But one of your future games may be huge, and every optimisation will help provide the best possible player experience.
Hope this helps!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.