How to display image after collision

xoidish

Member
Hello. I am new to Game Maker Studio 2 - Drag and Drop. I have been trying to make a PacMan horror game, but I've recently went on Reddit and asked on how to make a jumpscare. One of them said to simply display an image when the collision happens. They'd probably get mad at me for saying how to do it, so I'm posting it here. Any ideas?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
The simplest would be to create a new object and assign it the sprite you want to show on collision. Then in the create event of that object, set an alarm to however many frames you want the image to be shown. Next, in the alarm event, place a Destroy Instance action to remove the object again. Finally, in the collision event of the object that you want to produce the jump scare, call a Create Instance block and create the object you just made.
 

xoidish

Member
The simplest would be to create a new object and assign it the sprite you want to show on collision. Then in the create event of that object, set an alarm to however many frames you want the image to be shown. Next, in the alarm event, place a Destroy Instance action to remove the object again. Finally, in the collision event of the object that you want to produce the jump scare, call a Create Instance block and create the object you just made.
Wow! Thanks so much! I've just got 2 questions to ask.
1: How can I add sound the the jumpscare?
2: I don't have a Create Instance block, i'm using V2.3.3.437 and IDE v2.3.3.574.
Thanks for the help!
 

TheouAegis

Member
It should still be be a similar name, such as create instance at layer or create instance at depth. To play the sound, you just put the play audio action inside the create event of the jump scare object.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
  1. Create a new object and give it the sprite you want, ensuring the sprite origin is centered.
  2. In the object add a CREATE EVENT
  3. In the CREATE EVENT add a Set Alarm action for alarm[0] and set it to (for example) 60 (one second of game time)
  4. In the Alarm[0] event, add a Destroy Object Instance action
  5. Now, to create the instance use the action Create Object Instance in any object you want
  6. Make sure that the X/Y position for creating the instance is set to the middle of the room (room_width/ 2 and room_height / 2).

That's it really! If you are using views and cameras then the object will need to be created in the middle of the camera rather than the middle of the room.
 
Top