31
Programming Questions / Re: Is there a way to have a trigger change a room's background image?
« on: December 15, 2016, 11:40:24 AM »
Hi Plasma. There are multiple ways to do this.
Strategy 1: Create a new trigger object objTriggerChangeBg, this will be competely seperate from all the other trigger systems in the game. Set the sprite to sprTriggerMask, set visible to unchecked, and click Add Event -> Collision -> objPlayer. Drag "execute a piece of code" into the actions list. The code will be
Strategy 2: Use the existing trigger system. Create an object objEffectChangeBg, with no sprite. Click Add Event -> Step, drag "execute a piece of code" into the actions list. The code will be
Strategy 1: Create a new trigger object objTriggerChangeBg, this will be competely seperate from all the other trigger systems in the game. Set the sprite to sprTriggerMask, set visible to unchecked, and click Add Event -> Collision -> objPlayer. Drag "execute a piece of code" into the actions list. The code will be
Code: [Select]
background_index = bgIndex;
instance_destroy();
Place the object in the room, right click -> Creation code and assign bgIndex. (bgIndex = bgReallyCoolBackground;)Strategy 2: Use the existing trigger system. Create an object objEffectChangeBg, with no sprite. Click Add Event -> Step, drag "execute a piece of code" into the actions list. The code will be
Code: [Select]
if (global.trigger[trg]) {
background_index = bgIndex;
instance_destroy();
}
Place the object in the room, right click -> Creation code and assign trg and bgIndex. (trg = 5; bgIndex = bgReallyCoolBackground;) Also add an objFreeTrigger in your room and assign trg to be matching.