Bihos Posted December 11, 2018 Share Posted December 11, 2018 Hello, first of all forgive me for my English, it is very bad. I'm trying to rotate an Sprite based on the Tween. I add a tween for each point of the road as seen here: var tweens = []; for(var i = 1; i < path.length; i++){ var ex = path[i].x; var ey = path[i].y; if (i == path.length-1) { tweens.push({ targets: soldier, x: {value: ex*64+32, duration: 600}, y: {value: ey*64+32, duration: 600}, onComplete: onCompleteHandlerFinal }); } else { tweens.push({ targets: soldier, x: {value: ex*64+32, duration: 600}, y: {value: ey*64+32, duration: 600}, onComplete: onCompleteHandler, onStart: onStartHandler }); } } scene.tweens.timeline({ tweens: tweens }); and I have a function that rotates my object (Spirte), which receives the points x and y where it should point: rotate (to_x, to_y, delta){ let myPoint = new Phaser.Geom.Point(this.x+32,this.y+32); let pointTo = new Phaser.Geom.Point(to_x+32, to_y+32); this.rotation = Phaser.Math.Angle.BetweenPoints(myPoint, pointTo) + delta; } my idea is to rotate the image in the onStartHandler method, but I can not get the coordinates of the point where it is going. function onStartHandler (tween, targets, gameObject) { console.log(targets[0].x); console.log(tween.anyMethod()); //I need a method that returns the x coordinate //where the sprite goes in this tween } Link to comment Share on other sites More sharing options...
Recommended Posts