FEDE0D Posted July 21, 2014 Share Posted July 21, 2014 Hello, I'm new in this forum. I have a problem with the init function. This is my code:BgLava = game.TilingSprite.extend({ init:function(){ this._super('lava.png', game.system.width, game.system.height, {speed:{x:0, y:25}}); game.scene.stage.addChild(this); game.scene.addObject(this); var t = game.scene.addTween(this.speed, {x: 100}, 1000, {easing: game.Tween.Easing.Back.In}).repeat().yoyo().start(); } });I extend the TilingSprite class and I try to tween the speed of the sprite. But nothing happens.If I move this line: var t = game.scene.addTween(this.speed, {x: 100}, 1000, {easing: game.Tween.Easing.Back.In}).repeat().yoyo().start(); to the game.scene code it works perfectly. I've had some problems with the init method before but this one I can't solve. It's like the this inside init() it's different from the object that's being created.CLASS = Class.extend({ init:function(){ console.log(this); //<-1 }});//* Inside Scenevar c = new CLASS();console.log(c); //<-2It's not pointing to the same object? Is there a way to create a tween for the speed inside the init function? Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.