TrinityCore

Button Bug!

Recommended Posts

Hello Guys

 

I have a problem with the buttons on phaser

They do not change the texture as indicated in the code

Game: 

var PhaserGame = new Phaser.Game(1200, 640, Phaser.AUTO, "PhaserGame");
var Preload;
var MainMenu;
PhaserGame.state.add("Preload", Preload);
PhaserGame.state.add("MainMenu", MainMenu);
PhaserGame.state.start("Preload");

Preload:

Preload = {

	preload: function(){

	},

	create: function(){

		PhaserGame.load.onLoadComplete.add(Finished, this);
		Preloaders();

	},


	update: function(){},

}

function Preloaders(){
	PhaserGame.load.image("Background", "./images/Assest/Background001.png");
	PhaserGame.load.spritesheet("Button", "./images/Buttons/Button.png", 108, 48);
	PhaserGame.load.start();
}

function Finished(){
	PhaserGame.state.start("MainMenu");
}

MainMenu:

MainMenu = {

	preload: function(){
		
	},

	create: function(){

		Background = PhaserGame.add.tileSprite(0, 0, 1200, 640, "Background");
		Button = PhaserGame.add.button(10, 10, "Button", Tester, this, 0, 1);

	},

	update: function(){

	},

}

function Tester(object){
	console.log("Clicked");
}

The button does not change texture, and the mouse cursor changes state: Normal to Pointer, but steadily at the slightest movement on the button (without even getting out of it).

What could be the reason for this error?

Button:

Botton.png

I have tried with the following things:

1- Download the library again (Version 2.7.7).

2- Restart my computer.

3- Delete history, cookies, and everything that can be removed (Completely everything!).

4- Create all states from scratch.

What I can be doing wrong?

 

I hope you can help me.

Share this post


Link to post
Share on other sites
3 hours ago, ncil said:

Hello! I think the problem is with your actual button image file. The frames should go from left to right, not top to bottom. So your image should be 216x48 pixels. Try that.

No, the image is fine, the problem was that it was loading two identical files, one in the preload state and another in the state of MainMenu, which caused a kind of strange update.

Share this post


Link to post
Share on other sites
2 minutes ago, dami5200 said:

No, the image is fine, the problem was that it was loading two identical files, one in the preload state and another in the state of MainMenu, which caused a kind of strange update.

Oh gotcha. Glad you got it resolved :)

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.