Simulate butterfly movement

Hi,

I am a newbie of Corona, after struggling with my codes for a few days I’ve managed to make an object bouncing inside the screen.

Now I want to go further, I am looking for a way to make the object move more lively, just like a butterfly - flying toward a single direction, but a bit “shaky”.

I tried using setLinearVelocity, but the result is hardly satisfactory.

May I have any advices?
Jimmy [import]uid: 11908 topic_id: 33349 reply_id: 333349[/import]

Try this, play around with the numbers to get the effect you’re looking for:

[lua] function movingBf(event)

BfPosy = Bf.y
BfRotation = Bf.rotation

if BfRotation ~= nil then
Bf.y = BfPosy+math.cos(system.getTimer()/140)*-2.45
Bf.rotation = BsRotation+math.cos(system.getTimer()/162)*-.15
end
end
Runtime:addEventListener(“enterFrame”, movingBf)[/lua] [import]uid: 40033 topic_id: 33349 reply_id: 132440[/import]

Try this, play around with the numbers to get the effect you’re looking for:

[lua] function movingBf(event)

BfPosy = Bf.y
BfRotation = Bf.rotation

if BfRotation ~= nil then
Bf.y = BfPosy+math.cos(system.getTimer()/140)*-2.45
Bf.rotation = BsRotation+math.cos(system.getTimer()/162)*-.15
end
end
Runtime:addEventListener(“enterFrame”, movingBf)[/lua] [import]uid: 40033 topic_id: 33349 reply_id: 132440[/import]

Thanks buddy, your codes really help! [import]uid: 11908 topic_id: 33349 reply_id: 132609[/import]

Thanks buddy, your codes really help! [import]uid: 11908 topic_id: 33349 reply_id: 132609[/import]