Hello, It's my first time posting here, so apology if it's not done correctly. I have a problem. I have a game where I interpolate, via TweenLite, the position of a sprite. I interpolate the position of its box2D body to be precise. Even though the tweening in itself works fine, once I kill the tween, it puts back my object at its initial position and I can't figure out why. I am sure it's something stupid, like a param to pass, but can't find it in the doc. Maybe there are issues when tweening with box2D ? Thanks for your help. Code:
var fromX = ((BALL_SIZE * BALL_SCALE) / SCALE)
var toX = ((STAGE_WIDTH - (BALL_SIZE * BALL_SCALE)) / SCALE)
g_tween = TweenLite.fromTo(g_ball.sprite.body.GetPosition(), 3.0, {x:fromX}, {x:toX, ease:Linear.easeNone, onComplete:onTweenComplete, onReverseComplete:onReverseComplete});
function onTweenComplete() {
g_tween.reverse()
}
function onReverseComplete() {
g_tween.play()
}
// ***********
// Callback when user click on the screen
// The game release the ball if it hasn't been released yet
// ***********
function onMouseDown(event) {
//var newBall = new Ball()
//g_sprites.push(newBall)
var x = g_ball.sprite.body.GetPosition().x
console.log("x: " + x)
g_tween.kill()
g_ball.sprite.body.GetPosition().x = x
console.log("g_ball.sprite.body.GetPosition().x: " + g_ball.sprite.body.GetPosition().x)
g_world.SetGravity(new box2d.b2Vec2(0, 30))
}