【问题标题】:Variable Issue in GameMaker StudioGameMaker Studio 中的变量问题
【发布时间】:2016-10-13 22:36:45
【问题描述】:

在 obj_player 上我有一个 Create and Step 事件

创建:

/// Intialize Variables      
grav = 0.2;      
hsp = 0;     
vsp = 0;      
jumpspeed = 7;     
movepseed = 4;    
key_left = 0;
key_right = 0;
move = key_left + key_right;    

步骤:

//Get the player's input       
key_right = keyboard_check(vk_right);      
key_left = -keyboard_check(vk_left);    
key_jump = keyboard_check_pressed(vk_space);     

//React to inputs      
move = key_left + key_right;      
hsp = move * movespeed;      
if (vsp < 10) vsp += grav;      

if (place_meeting(x,y+1,obj_wall))        
{         
    vsp = key_jump * -jumpspeed        
}        

//Horizontal Collision     
if (place_meeting(x+hsp,y,obj_wall))         
{       
    while(!place_meeting(x+sign(hsp),y,obj_wall))       
    {          
        x += sign(hsp);        
    }       
    hsp = 0;         
}               
x += hsp;       

//Vertical Collision     
if (place_meeting(x,y+vsp,obj_wall))     
{        
    while(!place_meeting(x,y+sign(vsp),obj_wall))    
    {    
        y += sign(vsp);    
    }    
    vsp = 0;     
}       
y += vsp;    

错误信息:

___________________________________________
################################################################################    ############
FATAL ERROR in
action number 1
of  Step Event0
for object obj_player:

Variable obj_player.movespeed(100011, -2147483648) not set before reading it.
 at gml_Object_obj_player_StepNormalEvent_1 (line 8) - hsp = move * movespeed;
    ################################################################################    ############

这段代码有什么问题?我已经坚持了几天了,我真的很困惑,因为我已经看到了这段代码在运行中,并且对于这段视频中的其他人https://www.youtube.com/watch?v=IysShLIaosk(在我最初的问题之后,我从建议中添加了一些更改:)https://gamedev.stackexchange.com/questions/131436/variable-problem-in-gamemaker-studio

【问题讨论】:

  • 你能澄清一下你真正问的是什么吗? “Fix teh codez”对我们来说还不够……

标签: game-maker


【解决方案1】:

这只是印刷错误。仔细看Create事件,你在那里写“movepseed = 4;”

【讨论】:

    【解决方案2】:

    您在 obj_players 创建事件中拼错了 movespeed。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-09
      • 2018-05-05
      • 2022-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多