[Plugin] Shake Plugin

Post your completed addons to share with the community

Post » Mon Aug 19, 2013 7:52 am

Hello firebelly, I would like to know what's original formula of shake.

I'm trying to use it



It worked, but if we change value to Shake_Intense to 500, the object moves to right and bottom than current position.


Btw, I'm working a framework provides all samples, it will be open source, I will release it soon.
Joannesalfa2013-08-19 07:53:17
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Thu Aug 22, 2013 8:36 pm

Let me check on that!
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Fri Aug 23, 2013 5:35 am

Alternatively, to get working with shaking player while is moving with controls, I use Sine behavior and select movement type is Value.

Then, create an event:

-Every Tick
--Move at Angle, angle is random(0,360) and distance is a value from expression of Sine as "Value" as Return teh current oscillating value, it would work but it doesn't stay the original position, it keeps moving.
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Thu Aug 29, 2013 10:30 am

Link is dead man :(
B
7
S
1
Posts: 11
Reputation: 873

Post » Thu Aug 29, 2013 4:13 pm

[QUOTE=Nebuch] Link is dead man :([/QUOTE]

Woops, should be back now. Got a little excited with the old delete function...
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Wed Sep 04, 2013 10:43 pm

Wouldn't you help me?

If there is no chance, then no problem.
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Thu Sep 05, 2013 12:56 am

[QUOTE=Joannesalfa] Wouldn't you help me?

If there is no chance, then no problem.[/QUOTE]

HEre is the formula, what were you looking for particularly?

[CODE]
     if(runShake){
               // Get all instances with this behavior
               var all = this.behavior.my_instances.values();
               var sumx = 0, sumy = 0;
               var i, len;
               
               for (i = 0, len = all.length; i < len; i++)
               {
                    sumx += all.x;
                    sumy += all.y;
               }
               
               var layout = this.inst.layer.layout;
               
               // Is in a shake?
               var now = this.runtime.kahanTime.sum;
               var offx = 0, offy = 0;
               
               if (now >= this.behavior.shakeStart && now < this.behavior.shakeEnd)
               {
                    var mag = this.behavior.shakeMag * Math.min(this.runtime.timescale, 1);
                    
                    // Mode 0 - reducing magnitude - lerp to zero
                    if (this.behavior.shakeMode === 0)
                         mag *= 1 - (now - this.behavior.shakeStart) / (this.behavior.shakeEnd - this.behavior.shakeStart);
                         
                    var a = Math.random() * Math.PI * 2;
                    var d = Math.random() * mag;
                    offx = Math.cos(a) * d;
                    offy = Math.sin(a) * d;
               }
               
               layout.scrollToX((sumx / all.length + offx)+xOffset);
               layout.scrollToY((sumy / all.length + offy)+yOffset);          
          }
[/CODE]
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Thu Jul 09, 2015 11:19 pm

Tried this today and here is what I get. Help please?

Image
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Thu Mar 31, 2016 5:50 am

Got the same error
B
37
S
9
G
8
Posts: 541
Reputation: 8,554

Previous

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests