-
sathonoLikes 0Problem Description
Hello, I am trying to figure out a decent way of obtaining a objects delta speed horizontally and vertically when its running a MoveBy/To action. As of right now I am using a update loop and calculating the distance the moving object has moved to, every .01 seconds like this:
trackDistance:function() { if (this.prevX != -1) { this.moveX = (this.x - this.prevX); this.moveY = (this.y - this.prevY); } else if (this.prevX == this.x) { this.moveX = this.moveY = 0; this.unschedule(this.trackDistance); } this.prevX = this.x; this.prevY = this.y; },
This works relatively well, however the program cannot keep up when the objects are moving at high speeds, or if there is any lag. Is there any way to better approach this situation?
-
Sonar Systems adminLikes 0
How much do you have going on in the screen
-
sathonoLikes 0
Not to much is going on at the moment, however when I get further into development I do plan to have a extensive amount of objects present at once.
-
Sonar Systems adminLikes 0
You need to factor in delta, do you know how to do this?
-
sathonoLikes 0
Im not aware how exactly to approach this, would you be able to explain?
-
Sonar Systems adminLikes 0
Take a look at this http://cocos.sonarlearning.co.uk/docs/scheduling-methods
Login to reply