Jump to content

Tweening to exact values are failing


bluedot
 Share

Recommended Posts

Hi,

 

I've got 4 objects in a 2x2 grid, I'm using the following code to generate a tween where the object exchange positions with each other:

rotateLeft: function() {	    var tempX = this.diskGroup[0].x;    var tempY = this.diskGroup[0].y;        this.game.add.tween(this.diskGroup[0]).to( {x: this.diskGroup[2].x, y: this.diskGroup[2].y }, 2400, Phaser.Easing.Linear.None, true);    this.game.add.tween(this.diskGroup[2]).to( {x: this.diskGroup[3].x, y: this.diskGroup[3].y }, 2400, Phaser.Easing.Linear.None, true);    this.game.add.tween(this.diskGroup[3]).to( {x: this.diskGroup[1].x, y: this.diskGroup[1].y }, 2400, Phaser.Easing.Linear.None, true);    this.game.add.tween(this.diskGroup[1]).to( {x: tempX, y: tempY }, 2400, Phaser.Easing.Linear.None, true);},

However, each tween puts the objects slightly out of position so eventually the 2x2 grid is compromised. How do I make sure that the objects ends up in the exact position of the target ?

 

Thanks.

 

Link to comment
Share on other sites

Tweening should not be inaccurate, and should always place objects exactly at the position you tell it to. Tweened properties will always finish on the provided values.

 

I'd check to make sure the x and y positions you're feeding the tweens are correct. The only thing I can think of is that by using the positions of other objects that are also tweening, you may be getting them prematurely before the previous tween has finished. To ensure this doesn't happen I'd provide specific x and y coordinates to each object, rather than rely on the position of another object being exact when you read it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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