Forum Topic: "Shake" Class in AS3?

(116 views • 3 replies)

This topic is 1 page long.

<< < > >>
None

PrettyMuchBryce

Reply To Post Reply & Quote

Posted at: 8/21/09 05:04 PM

PrettyMuchBryce LIGHT LEVEL 06

Sign-Up: 03/17/01

Posts: 1,341

Where can I find the best 'shake' class to make an MC or array of MC's shake. I have one right now called earthquake but its garbage.


None

Afro-Ninja

Reply To Post Reply & Quote

Posted at: 8/21/09 05:10 PM

Afro-Ninja EVIL LEVEL 38

Sign-Up: 03/02/02

Posts: 13,467

make your own?

shaking isn't overly complicated. to shake something you just alternate its x/y position each frame, in either a predetermined or random direction. then just account for how long you want the shake to last- you could use a frame counter, a timer, or an interval.

BBS Signature

None

JoSilver

Reply To Post Reply & Quote

Posted at: 8/21/09 06:24 PM

JoSilver DARK LEVEL 15

Sign-Up: 09/21/07

Posts: 447

At 8/21/09 05:04 PM, PrettyMuchBryce wrote: Where can I find the best 'shake' class to make an MC or array of MC's shake. I have one right now called earthquake but its garbage.

well.... I there is something you can do but it require AS3 and a good VCAM and strong knoledge of AS3... Well, in flash CS3 (which I would recomend for this) when you make a motion tween you'll see that it when you right click on the frame of the tween the copy Motion As3 option will apprear...

I wont go any further for not but if you want know just ask cause this is gonna take a while to explain and you might not get it too...

The Future Ruler of Newgrounds-
Jo Silver
AS3 Main: CHECK IT OUT NOOBS!

BBS Signature

None

thedayturns

Reply To Post Reply & Quote

Posted at: 8/21/09 08:05 PM

thedayturns NEUTRAL LEVEL 01

Sign-Up: 08/08/09

Posts: 12

I am too nice to you guys.

var AMOUNT = 20; //adjust based on how much you want the movieclip to shake

function makeMcShake(which:MovieClip){
     which.defaultPos = {which.x, which.y}
     which.addEventListener(Event.EnterFrame, shake);
}

function stopMcShake(which:MovieClip){
      which.removeEventListener(Event.EnterFrame, shake);
      which.x = which.defaultPos.x;
      which.y = which.defaultPos.y;
}

function shake(e:Event){
    e.currentTarget.x = e.currentTarget.defaultPos.x + Math.rand() * AMOUNT - AMOUNT / 2;
    e.currentTarget.y = e.currentTarget.defaultPos.y+ Math.rand() * AMOUNT  - AMOUNT / 2;
}

All times are Eastern Standard Time (GMT -5) | Current Time: 02:34 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!