如何在 GameMaker Studio 中临时提高玩家速度?

问题描述 投票:0回答:1

我正在 GameMaker Studio 中制作《马里奥兄弟》克隆版,并希望添加一个能暂时提高玩家速度的道具。有什么简单的方法可以实现这一点,让速度提升持续一段设定的时间,然后恢复到正常速度?

目前,玩家的速度由变量player_speed控制。我正在寻找有关如何在 Mario 收集特定物品时应用速度提升并确保效果持续(例如 10 秒)的指导。

如何对这种临时速度提升进行编码,包括收集能量和速度提升持续时间?

game-maker
1个回答
0
投票

我认为这是一个想法的快速模型。注释行中的详细信息。 这个想法不一定要“获取”该物品,而是设置一个计时器,只要它处于活动状态,它就会为您提供速度提升。

创建活动

player_speed = 5;
player_speed_default = player_speed;
speed_Timer = 0
speed_multiplier = 1.5;

与通电对象的碰撞事件

speed_timer = 10; //sets the time to 10 seconds.
instance_destroy(other);

步骤事件

if (speed_timer > 0)
{
    speed_timer -= 1/room_speed; //counts down
    player_speed = player_speed * speed_multiplier; //adds the speed boost to the player's speed.
}
else
{
    player_speed = player_speed_default; //resets back to normal
}

x += player_speed; //adds movement to it's position
© www.soinside.com 2019 - 2024. All rights reserved.