I have some problems with the playButton

Hello everybody. I’m having trouble with creating the playButton (because I’m following the TurnBasedRPG tutorial).
It says to change on Main.hx the PlayState reference with MenuState, I did, but it doesn’t work for me and it gives me these errors. hope you can help me

I guess you are using HaxeFlixel, is that correct?

What tutorial exactly are you following?
What is the code that doesn’t work?
What are the errors you mention?

Hello, yes I’m using HaxeFlixel.

1)I’m using the official tutorial from HaxeFlixel website, called “TurnBasedRPG”
2)I don’t know what code are(sorry dude)
3)MIssing:
{
“resource”: “/home/(my name)/TurnBasedRPG/source/MenuState.hx”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “4”,
“severity”: 8,
“message”: “Missing ;”,
“source”: “diagnostics”,
“startLineNumber”: 9,
“startColumn”: 2,
“endLineNumber”: 9,
“endColumn”: 10
}
Unknown Identifier:
{
“resource”: “/home/(my name)/TurnBasedRPG/source/MenuState.hx”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “1”,
“severity”: 8,
“message”: “Unknown identifier : O”,
“source”: “diagnostics”,
“startLineNumber”: 12,
“startColumn”: 30,
“endLineNumber”: 12,
“endColumn”: 31
}
Unknown Identifier:
{
“resource”: “/home/(my name)/TurnBasedRPG/source/MenuState.hx”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “1”,
“severity”: 8,
“message”: “Unknown identifier : O”,
“source”: “diagnostics”,
“startLineNumber”: 12,
“startColumn”: 33,
“endLineNumber”: 12,
“endColumn”: 34
}
Unknown Identifier : Click Play:
{
“resource”: “/home/(my name)/TurnBasedRPG/source/MenuState.hx”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “1”,
“severity”: 8,
“message”: “Unknown identifier : clickPlay”,
“source”: “diagnostics”,
“startLineNumber”: 12,
“startColumn”: 45,
“endLineNumber”: 12,
“endColumn”: 54
}
here are you the complete errors
Also i use Linux

The code, or source code, is what you wrote. According to the errors there is something wrong in your MenuState.hx file, can you paste it here?

“Unknown Identifier” means you are using a name for a variable or function that doesn’t exist.
Names are case sensitive, clickPlay and ClickPlay would be different identifiers.

package;

import flixel.ui.FlxButton;

import flixel.FlxState;

import flixel.text.FlxText;

class MenuState extends FlxState

{var playButton:FlxButton

override public function create()

{playButton.screenCenter();

super.create();

playButton = new FlxButton(O, O, “Gioca”, clickPlay);

add(playButton);

}

override public function update(elapsed:Float)

{

super.update(elapsed);

}

}

function clickPlay()

{

FlxG.switchstate(new Playstate());

}

You seem to have some casing issues, it’s FlxG.switchState (uppercase on the second s) and you probably need new PlayState() (uppercase s).

In the new FlxButton (line 12) you have uppercase Os instead of zeros, which give you the “Unknown identifier : O” errors.

The line 9 var playButton:FlxButton needs a ; at the end, basically all line (all statements) ends with a semicolon.

1 Like

thank you ibilion! you’re a good man!