Game Maker 8.1: How to Create Shake Screen.
Visit my MC Anime site: https://mcanime1.wixsite.com/mcanime
Paypal Donate: http://bit.do/fkPAb
GM81 File: https://bit.ly/2ROqaYl
Note & Code File:
obj_shake, no sprite image required.
Events:
Create
Actions:
alarm[0] = 30;
Events:
Alarm 0
Actions:
view_xview = 0;
view_yview = 0;
Destroy Self
Events:
Step
Actions:
view_xview = random_range(-4,4);////If you take the numbers up, the screen will shake more, but only on images that use the view_xview and view_yview and if the room does not use d3d. Meaning, if you have an object or objects they will shake. This is used in end game room; d3d is turn off, and there is a object title in room, that will shake without the use of xview and yview.
view_yview = random_range(-4,4);
obj_shake2
The only thing different is the Actions for random range,
view_xview = random_range(-20,20);
view_yview = random_range(-20,20);///This is for end game room, Shakes alot more.
obj_facehit
Events:
Create
Actions:
Create Instance
Self
object: obj_shake
x: 0
y: 0
check Relative
Okay for any image that uses the Step and Draw and uses x and y view, if you do not want them to shake on screen, such as your inventory boxes or ammo count, just do this,
Delete your step info, and x and y view code. Use only the Draw for Event, then in the Actions, use this code for Draw, draw_sprite(sprite_index, image_index, x, y); these images on screen when you get hit will not shake, because you are not using the x and y view.
Example
obj_havegun2
Events:
Draw
Actions:
draw_sprite(sprite_index, image_index, 500, 200); ///the 500 and 200 are the horizontal and vertical location on screen. Just put in your x and y location.
Change something, which was not on video.
obj_faces, obj_healhim, I took out the step and change the Draw, so they will not shake, only the facehit will shake. If you want the obj_faces and obj_healhim to shake, just add the x and y views. Download my previous Game Maker link, to copy the Step and Draw Event back into the new_shake game maker to make those images shake using x and y views. It only makes sense when you hit something that his face will shake. Plus, there are three images of his face using different depths, and with all three of his face images shaking at once, it looks mess up.
Also in the obj_facehit I added code to deactivate the other faces when you get hit so it does not look so mess up with images behind the facehit.
Events:
Create
Actions:
instance_deactivate_object(obj_faces);
instance_deactivate_object(obj_healhim);
after the alarm stops and add them back in.
instance_activate_object(obj_faces);
instance_activate_object(obj_healhim);