Search the Community
Showing results for tags 'init'.
-
Does anyone know how to pass data into the game scene in Phaser 3 as you could do in Phaser 2 when started a state? game.state.start('Game', true, true, { data: 'this is some initial config' }); Phaser 3 Scene was Phaser 2 State, which you could provide parameters, the 2-3rd was as i remember caching, the 4th could be and data, which became available in the State's init() {} method as init({data}). In Phaser 3 a Scene has a second, data param, but it is not clear how it is used, the init method is not getting it, and the documentation is not ready for that as far as i know.
-
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!