Sprite Direction/Movement

In my game, i’m controlling the sprite character movement by the x and y position when the player touch the gamepads…

Simple as that: 

sprite.x = sprite.x + motionx;

He is moving, ok. But, he can move anywhere in the screen resulting in that: 

iw2m2d.jpg

The sprite is supposed to push the box, but he can push from anywhere… 

I want the sprite to push the box from point A to point B. The way he is moving right now this can be hard as the player and box not follows a path.

Is that confuse?

Think on a grid… I want always the character to move 1 cel to another, or 1 row to another. Not 1/2 of the current cel, or 1/4, always to another cell.

How can i accomplish that? 

For clarify a little bit, you can think as the classic: sokoban

http://sokoban.info/

see how the player moves like one frame to another? i want to do that, but using sprite animation…

nobody? :frowning:

In the Sokoban games I’ve played in the past, you don’t move by pixels, you move by blocks.  One press of the arrow key would move a whole grid square.  If your block is say a 40px block, you would move the block by 40px.  You would also move the player by 40px.  If you want the movement to be more smooth, then you could use a transition to animate moving from one block to the next block.

Rob

Yes, @Rob Miracle. But, the thing about the Sokoban is that you move one block to another by the arrow as you mentioned. 

So if the char is in the point A:

char 

and wanna to go to the point B:

A                        B 

char 

it would be something as: 

-> -> -> -> -> ->  (using the arrow)

in my game the player is free to use the gamepads as: 

-> (holding) 

the sprite will continue moving. 

Your advice me to do is use transition to. Would work in that circumstance? (I’ll have to make a map grid?) 

For clarify a little bit, you can think as the classic: sokoban

http://sokoban.info/

see how the player moves like one frame to another? i want to do that, but using sprite animation…

nobody? :frowning:

In the Sokoban games I’ve played in the past, you don’t move by pixels, you move by blocks.  One press of the arrow key would move a whole grid square.  If your block is say a 40px block, you would move the block by 40px.  You would also move the player by 40px.  If you want the movement to be more smooth, then you could use a transition to animate moving from one block to the next block.

Rob

Yes, @Rob Miracle. But, the thing about the Sokoban is that you move one block to another by the arrow as you mentioned. 

So if the char is in the point A:

char 

and wanna to go to the point B:

A                        B 

char 

it would be something as: 

-> -> -> -> -> ->  (using the arrow)

in my game the player is free to use the gamepads as: 

-> (holding) 

the sprite will continue moving. 

Your advice me to do is use transition to. Would work in that circumstance? (I’ll have to make a map grid?)