The ball keeps on going and going like the bunny we all know…
HELP!
i lost count how long i spent trying to figure this out
the 2 major changes that i did
- new build version (2012.806) (been doing it for a few versions)
- im using an object to store it in a table… (just tested the code with out the .object. same thing happens so point 2 is excluded)
ive been going in circles for days
here is a stripped down version of my code
can someone tell me if its working in their builds?
if not why wouldn’t it be working?
as always, thanks for any and all help!
[code]
local physics = require “physics”
physics.start(); physics.pause()
physics.setScale( 30 )
physics.setGravity( 0 , 0 ) --Top Down view no gravity…Earth y is 9.8
–physics.setDrawMode(“hybrid”)
– forward declarations and other locals
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
local ballbody = { density=0.8, friction=0.2, bounce=0.5, radius=15 }
local balls = {}
local function ballShot( event )
local t = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
– Stop current motion, if any
t:setLinearVelocity( 0, 0 )
t.angularVelocity = 0
elseif t.isFocus then
if “moved” == phase then
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
– Strike the ball!
t:applyForce( (t.x - event.x), (t.y - event.y), t.x, t.y )
end
end
– Stop further propagation of touch event
return true
end
–Spawn the ball Insert into a table for further use
local ball = {}
ball.object = display.newImage(“inkball.png”)
ball.object.id = “ball”
ball.object.alpha = 1
ball.object.linearDamping = 0.3 – Friction on the bg
ball.object.x = screenH/2
ball.object.y = screenW/2
ball.object.isBullet = true
ball.object:addEventListener( “touch”, ballShot )
physics.addBody( ball.object, ballbody )
table.insert(balls, ball)
physics.start()
[/code] [import]uid: 99036 topic_id: 25998 reply_id: 325998[/import]