how to animate an object in menu screen ?

Hey
I want to add some animations in the menu screen of my game. I want an object to keep on floating on the menu screen. To be specific, I want bubbles to keep on moving from bottom to top on my menu screen. It just moves (No interaction with the users). How can I implement this?

Thanks… [import]uid: 159148 topic_id: 37544 reply_id: 67544[/import]

[lua] --adding physics
local physics = require (“physics”);
physics.start();
physics.setGravity(-0.1 , -2.0) --Set to a negative value so the bubbles rise instead of fall

–Spawn bubbles at the bottom of the display
local function bubbleFloat()

local bubble = display.newCircle(0, 0, 22);
–Keeps the bubbles within the display and spawns them 35 pixels below the display
bubble.x = math.random(1, 768); bubble.y = (1024 + 35);
bubble.alpha = 0.6;
physics.addBody(bubble, {density = 0.1, bounce = 1.3, friction = 0.3, radius = 22});
print(" spawned bubble! ")

end
–Adding delay for function ‘bubbleFloat’
tmr = timer.performWithDelay(175, bubbleFloat, -0); [/lua]

Add your own bubble image, if necessary play around with the values until it feels right for your needs and you should be set. :slight_smile:

-Saer [import]uid: 148623 topic_id: 37544 reply_id: 145746[/import]

Thank you so much !! It works perfectly! :slight_smile: [import]uid: 159148 topic_id: 37544 reply_id: 145756[/import]

[lua] --adding physics
local physics = require (“physics”);
physics.start();
physics.setGravity(-0.1 , -2.0) --Set to a negative value so the bubbles rise instead of fall

–Spawn bubbles at the bottom of the display
local function bubbleFloat()

local bubble = display.newCircle(0, 0, 22);
–Keeps the bubbles within the display and spawns them 35 pixels below the display
bubble.x = math.random(1, 768); bubble.y = (1024 + 35);
bubble.alpha = 0.6;
physics.addBody(bubble, {density = 0.1, bounce = 1.3, friction = 0.3, radius = 22});
print(" spawned bubble! ")

end
–Adding delay for function ‘bubbleFloat’
tmr = timer.performWithDelay(175, bubbleFloat, -0); [/lua]

Add your own bubble image, if necessary play around with the values until it feels right for your needs and you should be set. :slight_smile:

-Saer [import]uid: 148623 topic_id: 37544 reply_id: 145746[/import]

Thank you so much !! It works perfectly! :slight_smile: [import]uid: 159148 topic_id: 37544 reply_id: 145756[/import]