【问题标题】:cannot change background during game play gamemaker?在玩游戏的时候不能改变背景?
【发布时间】:2018-05-07 20:25:54
【问题描述】:

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

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;

【问题讨论】:

    标签: game-maker


    【解决方案1】:

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

    示例 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 的背景位置将在屏幕之外,因此您看不到背景(背景平铺时除外)。

    【讨论】:

    • “因为创建事件只做一次”现在有意义了。
    猜你喜欢
    • 1970-01-01
    • 2011-01-30
    • 2014-12-16
    • 1970-01-01
    • 2013-04-14
    • 2021-11-18
    • 1970-01-01
    • 2014-04-15
    • 1970-01-01
    相关资源
    最近更新 更多