Jump to content

moving objects.


dthrasher90
 Share

Recommended Posts

Hey guys, Im still having trouble moving objects.  If I have a dot resting at (500,200) and I want to move him aloing the x axis for 50px and then up the Y axis for 50 px, how does one accomplish this?  I want to use increments and not coordinates, basically say, you go that way for 50 px and then this way for 50 px.

Link to comment
Share on other sites

You can call to/from consecutively to add to the timeline:

var tween = game.add.tween(/*…*/)
    .to(/*…*/)
    .to(/*…*/)
    .to(/*…*/)
    .start()

This is actually different from chaining tweens (I didn't know this at first!), which is

var tween = game.add.tween(/*…*/)
    .chain( game.add.tween(/*…*/) )

 

Link to comment
Share on other sites

Thanks!  This is what I had come up with:

  var tweenA = game.add.tween(wr1)
                .to({  x: '-200'}, 2000);
                var tweenB = game.add.tween(wr1)
                .to({  y: '+200'  }, 2000);

 

then in the function:

  tweenA.chain(tweenB);

tweenA.start();
 

Link to comment
Share on other sites

  • 4 weeks later...
 Share

  • Recently Browsing   0 members

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