Thanks for your code, i really appreciate it, i will put it as an alternative.
Is there no simple way to reduce the delay ?
If someone wanna try my sample project.
My test link http://cdn.redfoc.com/test/p3_tiles
If you go back to previous layout, the long delay are appear here.
My code
class load extends Phaser.Scene {
constructor(){
super('load');
}
preload(){
this.load.spritesheet('tiled', 'tiles.png', {frameWidth: 88, frameHeight: 64});
}
create(){
this.scene.start('menu')
}
}
class main_menu extends Phaser.Scene {
constructor(){
super('menu');
}
create(){
this.add.text(20,20, 'Press A to change scene',{fontFamily: 'Arial', fontSize: '30px',color: '#fff'});
this.input.keyboard.on('keydown', function(e,f){
if(e.key == 'a'){
this.scene.start('game')
}
}, this);
}
}
class main_game extends Phaser.Scene {
constructor(){
super('game');
}
preload(){
this.load.spritesheet('tiled', 'tiles.png', {frameWidth: 88, frameHeight: 64});
}
create(){
var size = {
w: 60,
h: 120
}
for(var y=0; y<size.h;y++){
for(var x=0; x<size.w; x++){
var o = this.add.sprite(x*88,y*64,'tiled');
o.setFrame(Math.round(Math.random()*3));
}
}
this.add.text(20,20, 'Press B to back to previous scene',{fontFamily: 'Arial', fontSize: '30px',color: '#fff'});
this.input.keyboard.on('keydown', function(e,f){
if(e.key == 'b'){
this.scene.start('menu')
}
}, this);
}
}
var config = {
type: Phaser.AUTO,
width: 1280,
height: 720,
scene: [load, main_menu, main_game],
}
var game = new Phaser.Game(config);