compiler-errors - 我对游戏制作人有一个神秘的错误

标签 compiler-errors game-maker

我的代码有误

这个程序应该允许我移动角色

我的错:

___________________________________________
COMPILATION ERROR in Script: player_movement
Error in code at line 11:
   var moveH = key_right - key_left;
             ^
at position 12: Unexpected symbol in expression.

我在互联网上进行了研究,但没有找到任何东西
// recuper touche des clavier
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_up = keyboard_check(vk_up);
key_down = keyboard_check(vk_down);



// mouvements du joueur

var moveH = key_right - key_left;

hsp = moveH * movesp;

var moveV = key_down - key_up;

vsp = moveV * movesp;

if (key_up && !place_meeting(x, y - 2, object_collision)) || (key_down && !place_meeting(x, y + 2, object_collision))
{
y += vsp;


} else if (key_right  && !place_meeting(x + 2, y, object_collision))|| (key_left && !place_meeting(x - 2, y, object_collision ))
{
 x += hsp;

}

//animation du joueur

if (hsp == 0) && (vsp == 0)
{
image_index = 0;
  image_speed = 0;
} else 
{
  image_speed = 1;
}


if key_right
{
 sprite_index = persoDroite;
} else if key_left
{
 sprite_index = persoGauche;
}else if key_up
{
 sprite_index = persoArriere;
}else if key_down
{
 sprite_index = persoFace;
}

最佳答案

如果您使用的是GameMaker 8,则不能执行var name = value,它必须是var name; name = value(或在分配之前声明变量),因此该行必须为

var moveH; moveH = key_right - key_left;

(您也可以将声明分组在一起,例如var moveH, moveV;)

关于compiler-errors - 我对游戏制作人有一个神秘的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58364744/

相关文章:

c++ - 如何将资源嵌入到单个可执行文件中?

game-physics - 我怎样才能访问 Game Maker 中的物理装置以便绘制它们?

compiler-errors - 隐式 super 构造函数

c - 错误 : wide character array initialized from incompatible wide string

c - ':' token 之前应为 ',' 、 ';' 、 '}' 、 '__attribute__' 或 '='

2d - 如何在gml代码中判断物体是否被玩家触摸

http - 在 Gamemaker Studio 中使用 TCP(或其他任何方式)转发端口

c++ - 无法在 Linux 上编译 C++ 代码,但可以在 Mac OS 上编译

java - 包与 Java 9 中的自动模块冲突

memory - ds_map 会破坏子 map 吗?