Page 1 of 1

shaking the screen

PostPosted: Fri Jul 15, 2011 9:41 pm
by raminjoon
hi I was wondering to know if you know how I can shake the scene after a event. I mean I want make some kind of earthquake for example in my game do you have any idea?

Re: shaking the screen

PostPosted: Fri Jul 15, 2011 9:47 pm
by skydereign
What this is one way to do it. You should have some way of telling where the view should be, and something tell the view to shake. So, for this I I'm going to use the variables xview, yview, and quake.
view -> Draw Actor -> Script Editor
Code: Select all
x=xview;
y=yview;

if(quake==1)
{
    x=xview-10+rand(20);
    y=yview-10+rand(20);
}


This way you set quake to 1, and it will start shaking by a max of 10 pixels in either direction.

Re: shaking the screen

PostPosted: Fri Jul 15, 2011 9:55 pm
by raminjoon
thanks friend but can I do that by have this code activated for example after a certain event has occured?

Re: shaking the screen

PostPosted: Fri Jul 15, 2011 9:59 pm
by skydereign
Well to activate that code you can use any event, and just set quake to 1. If you want it to stop set it to 0. The thing is unless the shaking only happens while you are pressing a key, you'll have to use a draw actor event.

So, this will activate it.
player -> Key Down x -> Script Editor
Code: Select all
quake=1;

And if you want it to stop after a while you can use a timer event that sets it back to 0.