For example :-
If the player touches (object) then he gets a bonus and he can move faster for 30 seconds
when 30 seconds is over … he is back to it’s original state
Hope someone can help …
For example :-
If the player touches (object) then he gets a bonus and he can move faster for 30 seconds
when 30 seconds is over … he is back to it’s original state
Hope someone can help …
Try this:
At the beginning :: Pause timer (this is only to initialize a timer, not required really but doesn’t hurt)
If player is in collision with object :: Set bonus = 1
If bonus = 1 :: Unpause timer and Set player speed to fast
If timer >= 30 seconds :: Pause timer, Reset timer, Set player speed back to normal and Set bonus = 0
I hope it helps.
Cool it worked thanks a lot … so this will work on any bonus i give to the player right ?
If the player can have multiple bonuses active at the same time, you going to need at least a different timer and a different bonus variable for each bonus you have in your game like
if Player is in collision with speedBonusItem then speedBonusVariable = 1
If speedBonusVariable = 1 then Start speedBonusTimer…etc
Replace speedBonusVariable and speedBonusTimer for each different bonus you have.
Otherwise, if only 1 bonus can be active at the time, it should be ok for any bonus.
oh very good then i will make a variable for each bonus … oh btw do scene variables affect the fps of the game ? … i heard so many global var. can affect the fps of the game … i don’t know . who is right ?
Global variables can effect the performance in that regard your game is going to be using more memory because scene variables store information only as long the scene is running and global variable store information as long the entire game is running. In case the device doesn’t have enough memory, it could be an issue if you store everything in global variables, even things that you no longer need after the first level.
Practically, you want to use Scene variables to store information that you need only as long the scene is running and it is different for each scene like number of enemies in the scene for example, and you want to use Global variables to store information that you need as long the game is running and you need to access that information in any scene throughout the game because it is same for all the scenes, like the sound and music volume for example.
Alright scene var. seems good to me .