Well, looks like I have to resort back to the forums again. In my little game I’m having objects falling and a little guy catching. I have 8 objects total. 4 for + points and 4 for - points. For a start, I have the 1st object falling 10 times and adding to the score if caught. I’m kinda lost. First, I can’t get the object to disappear if it hits the ground and having the 3 other objects adding values to the score. Also the other 4 ‘bad’ objects adding - value. Along with having a continuous flow of the objects falling instead of a set number. I tried to create different functions and tables and just can’t get it right.
score = 0
frameCounter = 1
objectsDropped = 10
function onLocalCollision(self,event)
if(event.phase == “began”) then
if(self.id == “object1”) then
if(event.other.id == “player”) then
vx, vy = self:getLinearVelocity()
if(vy > 3) then
score = score + 1
scoreText.text = tostring(score)
self.isVisible = false
self:removeSelf()
end function/ifs
local object1 = display.newImage( “object1.png”, 180, -100)
object.rotation = 10
physics.addBody(object1, {density = 2.0, friction = 1.5,bounce=0.3})
object1.id = “object1”
object1.collision
object:addEventListener(“collision”, object1)
local function onFrame(event)
frameCounter = frameCounter + 1
objectsDropped = objectsDropped - 1
local object1 = display.newImage( “object1.png”)
object1.x = math.random(0, 310)
object1.y = 0
object1.rotation = math.random(0,360)
physics.addBody(object1, {density/friction/bounce})
object1.id = “object1”
object1.collision = onLocalCollision
object1.addEventListener(“collision”, object1)
end function/if
Runtime:addEventListener(“enterFrame”, onFrame) [import]uid: 114389 topic_id: 22264 reply_id: 322264[/import]