Nice performance trick I coded up
Hey Guys I coded a nice little trick that will really save you on performance if you are making something like an endless runner, or any app that uses actors that need to have a certain speed at certain intervals.
Basically, in the case of an endless runner, instead of having a lot of rules for them to speed up or slow down according to the score, you can do this.
Create a scene attribute (integer), for example BadGuy01Speed, something say like 200.
Then, in your badguy actor, just put a change attribute, self.motion.linear velocity.x TO badguy01speed.
The good thing is you don't even need to constrain it, so that saves some processing power to.
And finally, to change their speed, you can use a scoring event technique to change the scene integer attribute triggered by a self attribute. (i.e. very similar to whats on the cookbook) For instance:
When self.speed up > or = to game.score
Change att: badguy01speed to badguyspeed01+50
Change att: self.speed up to seld.speedup+1000 (or whenever you want the change to occur)
Hope this makes sense and might help somebody out, saved me a ton of processing power.
Have a good one everybody!
Jordan
**********************************************************************
www.jordanmorganapps.com
Basically, in the case of an endless runner, instead of having a lot of rules for them to speed up or slow down according to the score, you can do this.
Create a scene attribute (integer), for example BadGuy01Speed, something say like 200.
Then, in your badguy actor, just put a change attribute, self.motion.linear velocity.x TO badguy01speed.
The good thing is you don't even need to constrain it, so that saves some processing power to.
And finally, to change their speed, you can use a scoring event technique to change the scene integer attribute triggered by a self attribute. (i.e. very similar to whats on the cookbook) For instance:
When self.speed up > or = to game.score
Change att: badguy01speed to badguyspeed01+50
Change att: self.speed up to seld.speedup+1000 (or whenever you want the change to occur)
Hope this makes sense and might help somebody out, saved me a ton of processing power.
Have a good one everybody!
Jordan
**********************************************************************
www.jordanmorganapps.com
Comments
Thanks for sharing!