玩游戏时不能改变背景?

cannot change background during game play gamemaker?

我在创建事件时使用它来在游戏过程中更改背景。但是不会改变背景,知道吗?

seconds = current_second;

if seconds < 30
{
    background_index[0] = background0;
    background_visible[0] = true;
}

if seconds > 30
{
    background_index[5] = background5;
    background_visible[5] = true;
}

// Set background
background_hspeed[0] = -2;
background_hspeed[5] = -2;

我不明白你的目标,举几个例子:

示例 1.

创建活动:

background_index[0] = background0;
background_index[1] = background1;

步骤事件:

seconds = current_second;

if seconds < 30
{
    background_visible[0] = true;
    background_visible[1] = false;
}
else 
{
    background_visible[0] = false;
    background_visible[1] = true;
}

示例 2. 相同,但使用警报

创建活动:

background_index[0] = background0;
background_index[1] = background1;

event_perform(ev_alarm, 0);

报警 0 事件:

seconds = current_second;

if seconds < 30
{
    background_visible[0] = true;
    background_visible[1] = false;
}
else 
{
    background_visible[0] = false;
    background_visible[1] = true;
}

alarm[0] = room_speed * 30;

示例 3. 其他想法...

创建活动:

background_index[0] = background0;
background_index[1] = background1;
background_visible[0] = true;
background_visible[1] = true;

event_perform(ev_alarm, 0);

报警 0 事件:

seconds = current_second;

if seconds < 30
{
    background_index[0] = background0;
    background_index[1] = background1;
}
else 
{
    background_index[0] = background1;
    background_index[1] = background0;
}

background_x[0] = 0;
background_x[1] = 0;
background_hspeed[0] = 0;
background_hspeed[1] = -2;

alarm[0] = room_speed * 30;

如果您需要多次更改背景,那么您需要使用 step 事件或警报,因为 create 事件只执行一次。另外当你使用滚动时,你需要记住一段时间后 x 背景的位置将在屏幕之外,所以你看不到背景(除非你的背景是平铺的)。