Jump to content

The init problem


FEDE0D
 Share

Recommended Posts

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); //<-2

It's not pointing to the same object?

 

Is there a way to create a tween for the speed inside the init function?

 

 

Thanks!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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