-
1. Re: im trying to create a "wobbling" effect with a bitmap
Rod@FOF Apr 28, 2014 10:53 AM (in response to pletkip)It somewhat depends on what the effect is intended to acheive.
Here is a simple behavior script that can be applied to any bitmap. It wobbles, in the sense that it has a radom movement about its axis.
That is acheived with the random() statements. The amount of wobble can be controlled by changing the value added to each parameter on each iteration.
The last three statements keep the wobble from randomly walking off the frame. Again, wobble can be changed by setting the corrective value at which point the bitmap returns to its original state.
Hope this helps.
------------------------------------------------------------------------------------------ -----------------
property spritenum
global glocH, gLocV, gRotation
On beginsprite
gloch = sprite(spritenum).loch
gloch = sprite(spritenum).locv
gRotation = integer(sprite(spritenum).Rotation)
end
On enterframeb = random(2)
if b=1 then
sprite(spritenum).loch = sprite(spritenum).loch + random(2)
else
sprite(spritenum).loch = sprite(spritenum).loch - random(2)
end if
c= random(2)
if c=1 then
sprite(spritenum).locv = sprite(spritenum).locV + random(2)
else
sprite(spritenum).locv = sprite(spritenum).locV - random(2)
end if
d= random(2)
if d=1 then
Sprite(spritenum).rotation = sprite(spritenum).rotation + random(4)
else
Sprite(spritenum).rotation = sprite(spritenum).rotation - random(4)
end if
if abs(gloch + sprite(spritenum).loch) <= 8 then sprite(spritenum).loch = gloch
if abs(glocv + sprite(spritenum).locv) <= 8 then sprite(spritenum).locv = glocv
if abs(Integer(gRotation - sprite(spritenum).Rotation)) >=8 then sprite(spritenum).rotation = gRotationend

