Game Development Community

Question on movement of objects

by Adam Emrick · in General Discussion · 09/27/2011 (9:42 pm) · 3 replies

Where can I find more information on the movement of a sprite object? Specifically, functions similar to the example given in the rainx demo:
%this.setLinearVelocityX(-20);
%this.setFlipX(true);
I would implement the different rotations, such as going at an angle. (say northeast) Which segment of the documentation handles the movement functions?

Thanks a ton

#1
09/30/2011 (10:12 am)
How do I make my object move diagonal? Also, what is the easiest way to implement the desired transformation of the image that is consistent with the direction I'm moving? So if going toward the top right of the screen, the image would move where it was facing top right? Thanks for looking at my post.
#2
10/06/2011 (5:06 am)
Anything at all would be helpful. I'm not sure where to look up the movement functions.
#3
11/10/2011 (11:39 pm)
For posterity, some sample code to move an object in circles:

function YourObjectClass::onWorldLimit(%this, %mode, %limit)
{
%speed = 100;
// Set up a string comparison switch based on the %limit
switch$ (%limit)
{
case "bottom":
%this.setLinearVelocityX(0);
%this.rotateTo(130, (%speed * 2));
%this.setLinearVelocityPolar(125, %speed);
%this.dump(); //this is useful for debugging

case "top" :
%this.setLinearVelocityX(0);
%this.rotateTo(-50, (%speed * 2));
%this.setLinearVelocityPolar(250, %speed);


case "left":
%this.setLinearVelocityX(0);
%this.rotateTo(-125, (%speed * 2));
%this.setLinearVelocityPolar(125, %speed);

case "right":
%this.setLinearVelocityX(0);
%this.rotateTo(75, (%speed * 2));
%this.setLinearVelocityPolar(25, %speed);

}
}