Jump to content

text disappear


gzaikun
 Share

Recommended Posts

Hello everyone

 

I have a problem with text phaser, when called from another prototype text suddenly disappeared.

 

Boot.js

var Core = {	ver   		: '0.0.1',};var timeCheck;var text;Core.Boot = function(game) { 	this.game = game;};Core.Boot.prototype = {	preload: function() {		console.log('Boot preload - ok');                this.game.stage.backgroundColor = '#5c5c5c';	},	create: function() {		console.log('Boot create - ok');		timeCheck = this.game.time.now;	},	update: function() {		if (game.time.now - timeCheck > 5000) {			this.game.state.start('Preloader');		}	},	loading: function() {		game.load.onLoadStart.add(this.loadStart, this);	        game.load.onFileComplete.add(this.fileComplete, this);	        game.load.onLoadComplete.add(this.loadComplete, this);		game.load.start();	},	loadStart: function() {		text.setText("Loading ...");	},	fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {		text.setText( progress + "% - " + totalLoaded + " / " + totalFiles);	},	loadComplete: function() {		text.setText("Complete");	},}

Preloader.js

Core.Preloader = function(game) { 	this.game = game;};Core.Preloader.prototype = {	preload: function() {		console.log('Preloader preload - ok');                text = this.game.add.text( 32, 32, 'Loading', { fill: '#ffffff' });		this.game.load.image('sky', 'assets/img/sky.png');	        this.game.load.image('ground', 'assets/img/platform.png');	        this.game.load.image('star', 'assets/img/star.png');	        this.game.load.spritesheet('dude', 'assets/img/dude.png', 32, 48);		test = new Core.Boot();		test.loading();	},	create: function() {		console.log('Preloader create - ok');	},	update: function() {			}}
Link to comment
Share on other sites

You normally only put a loading screen/text in your preloader.preload function and load the assets. If you want to change backgrounds and use more text you'd put it in the create function of the state the game is in.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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