First of all, excuse the newbness. I’m not only new to Corona, but also Lua (previously a professional web developer). That said, I feel like I’m picking both up pretty quickly, but have ran into a small problem I was hoping I could get some community help with.
I’m attempting to build a simple pinball game, which is really just practice/prototype for a larger idea I’ve got in mind. So far I’ve got some very basic elements in place - paddles which rotate correctly when you touch them, a ball which falls, etc.
The problem I’m finding is the interaction between the paddles and the ball being very “squishy” (for lack of a better word). I touch the paddle when the ball is near, the paddle moves quickly, and while the paddle does obviously interact with the ball (moving it a bit), the paddle also passes through the ball to some degree, producing a very unrealistic/unconvincing effect. At best it feels like they’re on top of each other, at worst they seem to be slowing each other down.
What I want (like in a real pinball game) is there to be a clear physical interaction between the paddle and ball, which shoots the ball upward (in an appropriate angle based on the interaction) realistically.
Admittedly my knowledge of physics is not what it used to be, but in the case of Corona they seem to be pretty simple (which is good I think). I’ve played with the bounce, density, friction, as well as the various body types. So far nothing has been able to add a real obvious “connection” between the objects.
I believe this is possible as I saw an example of a released hybrid Soccer/Pinball game written in Corona, but it unfortunately did not expose any code. ):
For reference my basic code follows:
[lua]local physics = require(“physics”)
physics.start()
– Ball
local ball = display.newImage(“ball.png”)
ball.x = 100
ball.y = 0
physics.addBody(ball, { friction=.8; bounce=0.5; radius=14; density=1.5; } )
– Left Paddle
local lPaddle = display.newImage(“lPaddle.png”)
lPaddle.x = 70
lPaddle.y = display.contentHeight - 30
lPaddle.xScale = 1
lPaddle.yScale = 1
lPaddle:setReferencePoint(display.CenterLeftReferencePoint)
physics.addBody(lPaddle, { friction=.8; bounce=0.1; density=1.5 } )
lPaddle.bodyType = “kinematic”
– Events
function moveLeftPaddle(event)
transition.to(lPaddle, { time=150; rotation=-90; })
transition.to(lPaddle, { time=150; delay=100; rotation=0; })
end
lPaddle:addEventListener(“touch”, moveLeftPaddle)[/lua]
Thanks ahead for any help. Challenges aside, I’ve been highly impressed by both this tool and the community (and Lua is pretty awesome too).
=Luke
[import]uid: 10553 topic_id: 3098 reply_id: 303098[/import]