我正在创建一个改变主角精灵的角色选择。
为此,我有一个箭头对象,用户单击它可以更改主角的精灵。
global.Mario = true;
global.PrincessPeach = false;
global.Luigi = false;
global.Bowser = false;
if (mouse_check_button_pressed(mb_left)) {
if (global.Mario = true) {
Mario = false;
PrincessPeach= true;
}
if (global.PrincessPeach= true) {
PrincessPeach = true;
Mario = false;
}
if (global.Luigi = true) {
Luigi = false;
Bowser = true;
}
if (global.Bowser = true) {
Bowser = false;
Mario = true;
}
}
然后,在我的主角上,我创建了一个事件执行代码,类似于以下内容:
if (global.Mario = true) {
sprite_index = Mario_NotJumping;
}
if (global.Luigi = true) {
sprite_index = Luigispr;
}
但是,当我运行我的游戏进行测试时,我收到以下错误:
FATAL ERROR in
action number 1
of Create Event
for object Mario_selection:
Push :: Execution Error - Variable Get -5.Mario(100000, -1)
at gml_Object_Mario_selection_Create_0 (line 1) - if (global.Mario = true) {
该对象Mario_selection
具有与主角完全相同的创建事件和相同的代码。向用户显示更改。
如果有人可以帮助我,我对 GameMaker 还很陌生,所以我觉得我只是误解了全局变量。