Jump to content

Strange Behavior: spacebar = tween sprite "+20" doesn't stop moving...


Krautman
 Share

Recommended Posts

Hey Guys, 

1st try with phaser, so maybe I'm missing a really basic point. I've looked into the API and examples of tweens but I'm slowly getting mad over here. 

I'm trying to make my player move in an isometric world. I want him to move grid by grid and not smoothly as long as a curser is held down. E.g. user pressed "Right" player moves "one unit" to the right. not more or less. "one unit" is a constant and has currently the value of 20. 

I'm using this iso-plugin (http://rotates.org/phaser/iso/).

My current approach is to call a function on space.onDown with the following line: 

game.add.tween(player).to({ isoX: '+20' }, 100, Phaser.Easing.Linear.None, true);

well, what happens now is that the player is moved from starting point isoX = 128 to isoX = 368,4 (wtf!) I would expect it to move to isoX = 148. 

if I press a second time spacebar the player is correctly moved to 388,4. A third time is also working fine and so on.

I just don't know why the first time the player is moved to a kind of worldbounds or something...really strange

You can try for yourself and see the whole code at:

http://www.jungbrunnen.koeln/sandbox/phaser/isometric/boxes.html

PS: maybe my approach is all bogus. Is there a better way of doing this?

thanks for any help and advice!

 

Link to comment
Share on other sites

thx for your answers!

@samid737 it works but doesn't solve my problem...later on I would like to animate the movement of the player. I thought using a tween for moving and a second for animation would be the right approach. Just changing the position is pretty ugly...do you have any idea where to look for bugs?

@samme I've updated to v2.8.8 - same output :/

any ideas?

 

 

Link to comment
Share on other sites

EDIT: I didn't find anything related on github but I changed my player-obj to a simple sprite instead of the IsoSprite from the plugin and it worked on flat 2D as expected. Therefore I believe it's an issue of the isometric plugin.

Well this won't make the bugfixing easier since it's no longer supported...but it's a starting point I guess...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...