A bounce that never stop

Hi, can you show me how can I do a bounce that never stop? For example, if a ball fall down to the floor, it will continue bouncing forever without losing energy, and then, how can I put a default image (for my company) that appear when I launch my app and after 3 second the application bring the user to a file called “titleScreen.lua”?

Thanks a lot! [import]uid: 76800 topic_id: 21651 reply_id: 321651[/import]

There are multiple ways of doing that, one way would be to apply force to the ball when it hits the floor, that should be very consistent.

RE the splash screen, that’s automatic - just put in a Default.png image and it will show as the splash :slight_smile:

Peach [import]uid: 52491 topic_id: 21651 reply_id: 86065[/import]

Here is a sample code for the CompanyLogo Screen :wink:

You will add this into “Main.lua”

[lua]display.setStatusBar (display.HiddenStatusBar)
----- hide status bar-------------

_W = display.contentWidth; _H = display.contentHeight;

local director = require (“director”)
--------must have when using director------

local mainGroup = display.newGroup()

splash = display.newImage(“Default.png”); splash.x = _W/2; splash.y = _H/2
–Name your companylogo to “Default.png”—
–The code above places the image in the center of the screen

local function main()

splash:removeSelf()
splash = nil

mainGroup:insert(director.directorView)

director:changeScene(“titleScreen”)

-------Change-Sceen-------
return true
end

timer.performWithDelay(1000, main, 1) [import]uid: 119384 topic_id: 21651 reply_id: 86121[/import]

Keep in mind for the above you would need to be using director. (There’s a tutorial on Techority if you are unfamiliar with it thus far.)

Peach :slight_smile: [import]uid: 52491 topic_id: 21651 reply_id: 86266[/import]

Hi, I have tried to accomplish the same (Constant Bounce), but I can’t get it to work with the applyforce. Any suggetions how I can accomplish this? :smiley:

I really appreciate your help, thank you in advance. [import]uid: 122802 topic_id: 21651 reply_id: 86448[/import]

Thanks a lot! I finally solved my problem! [import]uid: 76800 topic_id: 21651 reply_id: 86503[/import]

se460, you can use force or you can tweak settings until you get it right.

EG;

[lua]require ( “physics” )
physics.start()
physics.setGravity( 0, 9.5 )

local ground = display.newRect( 0, 460, 320, 20 )
physics.addBody(ground, “static”, {bounce=0})

local ball = display.newCircle( 160, 60, 30 )
physics.addBody(ball, “dynamic”, {bounce=0.97})[/lua]

Try running that.

Peach :slight_smile: [import]uid: 52491 topic_id: 21651 reply_id: 86550[/import]

Hi Peach, thank you for the code, it seems to work, but I have one problem after some time the ball/image starts to jump higher and higher. Is there a way to eliminate that? :smiley:

This is my code (Almost exactly like the code you posted above):

[code]require ( “physics” )
physics.start()
physics.setGravity( 0, 9.5 )

local ground = display.newRect( 0, 460, 320, 20 )
physics.addBody(ground, “static”, {bounce=0})

local ball = display.newImage(“Goat.png”, 70, 250 )
physics.addBody(ball, “dynamic”, {bounce=0.97})[code] [import]uid: 122802 topic_id: 21651 reply_id: 86606[/import]

Try this instead;

[lua]require ( “physics” )
physics.start()
physics.setGravity( 0, 9.5 )

local ground = display.newRect( 0, 460, 320, 20 )
physics.addBody(ground, “static”, {bounce=0})

local ball = display.newCircle( 160, 260, 30 )
physics.addBody(ball, “dynamic”, {density=0.2, friction=0.1, bounce=0.1, radius=30})

function ball:collision (event)
if event.phase == “ended” then
ball:applyForce(0,-150, ball.x, ball.y)
end
end
ball:addEventListener(“collision”, ball)[/lua]

Let me know how that goes :slight_smile: [import]uid: 52491 topic_id: 21651 reply_id: 86638[/import]

Hi Peach, thank you very much for your help, it works like a charm :slight_smile:

[import]uid: 122802 topic_id: 21651 reply_id: 88067[/import]

Not a problem, good luck with your project :slight_smile: [import]uid: 52491 topic_id: 21651 reply_id: 88111[/import]