Hi everyone, i.m fairly new to CORONA SDK.
I need to create button that resets the ball to its original position when it is pressed by the player.
here is my code so far… (Note: I have tried playing with the button widget and I can get a button to display, it’s making it perform the action of resetting the balls position that I’m struggling with. I have searched the internet for the past hour or so to no avail. Hopefully someone here can help me.
Best Regards,
Chris
display.setStatusBar( display.HiddenStatusBar )
[html]
– Create a background colour
local back = display.newRect(0, 0, display.contentWidth, display.contentHeight)
back:setFillColor(165, 210, 255)
–Adding physics
require(“physics”)
physics.start()
–Creating the ball
local myCircle = display.newCircle(display.contentWidth /15, display.contentHeight /8 -25, 12.5, 12.5 )
myCircle:setFillColor(255,0,0)
–Add physics to the ball
physics.addBody( myCircle, “dynamic”, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 12.5 } )
local ballretainer = display.newRect(0, 0, 25,25)
ballretainer:setFillColor(0, 210, 255)
ballretainer.xOrigin = display.contentWidth /15
ballretainer.yOrigin = display.contentHeight / 8
physics.addBody( ballretainer, “static”, { friction=0.5, bounce=0.3} )
function ballretainer:touch( event )
if event.phase == “began” then
self.markX = self.x – store x location of object
self.markY = self.y – store y location of object
ballretainer:removeSelf()
end
return true
end
ballretainer:addEventListener( “touch”, ballretainer) [import]uid: 173546 topic_id: 31010 reply_id: 331010[/import]