2015-05-18 33 views
0

我在事件創建時使用它來改變遊戲過程中的背景。但不會改變背景,任何想法?在遊戲玩家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; 

回答

0

我不明白你的目標,所以舉幾個例子:

例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背景的位置將在屏幕之外,所以你看不到背景(除了背景平鋪的情況)。

+0

「因爲創建事件只做一次」現在它是有道理的。 –