Okay I have made a gui that has four buttons (New Game, Load Game, Credits and Quit). Anyway for example the name for New Game is "newgame", I have put this code in the globalscript
function NewGame_OnClick(GUIControl *control, MouseButton button)
{
gStart.Visible = false;
cEgo.ChangeRoom (2);
}
But it doesn't seem to work, any ideas?
You don't need a space in cEgo.ChangeRoom (2); but I doubt that's causing issues.
Select the newgame button by clicking on it
once in the GUI editor. Then click the lightning icon down the bottom right - in OnClick it needs to have a link to newgame_OnClick, or it won't call it in the Global Script. If you've put that code there yourself, rather than having it auto-generated by AGS, the two won't necessarily be linked. Click the ... button to auto-generate a 'definitely right' function, and delete yours.
ALSO: functions are case-sensitive... so it should be
Quotefunction newgame_OnClick(GUIControl *control, MouseButton button)
... if your button name is all lowercase (ie newgame not NewGame) ;)
Thanks for that I didn't realise you had to double click to link them up.
I appreciate it :)