Jump to content

How to remove delay when changing the game state ?


delta9
 Share

Recommended Posts

You're firing the state change at the end of tweenB, which is when the shutters finish opening again. What you need to do is fire it inside the topOut onComplete event, then start the next scene with the shutters already in the closed position, and tween them open.

 

I have tried to do so. but when I place the shutter closed, they instantly overlap by  background of the current state 
 
where should I place the code that pushes out the shutters? in "preload" function? or "init"
Link to comment
Share on other sites

You should be doing any setup in either preload or create - init will be too early. I'd recommend setting the shutters to closed in the 'preload' function of the next state, then tween them open in the 'create' function. This will keep the shutters closed until the state has loaded, then it will open them.

Link to comment
Share on other sites

You should be doing any setup in either preload or create - init will be too early. I'd recommend setting the shutters to closed in the 'preload' function of the next state, then tween them open in the 'create' function. This will keep the shutters closed until the state has loaded, then it will open them.

 

I followed your advice. Here is the result, and the source code here (l.44)
 
the result is negative -  these shutters  not visible.
 
 
Workaround: not quite what I need, but ... :
create: function () {topOpen = this.add.tween(this.splashTop).to({x:-200, y:-200}, 1400, Phaser.Easing.Linear.None, true);bottomOpen = this.add.tween(this.splashBottom).to({x:this.world.x+280, y:this.world.y+280}, 1400, Phaser.Easing.Linear.None, true);bottomOpen.onComplete.add(function(){  this.add.sprite(0, 0, 'mainMenuBack');  this.mainPlayButton = this.add.button(this.game.world.centerX-100, this.game.world.centerY, 'mainPlayButton', this.startPlay, this, 0, 1, 0);  this.mainPlayButton.inputEnabled = true;  this.mainPlayButton.input.useHandCursor = true;}, this);}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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