Im making a game where the level transition is based on a star landing and coming to a rest on a goal(platform), the problem is that I need the alert for the next level to only come up when not only is the star on the goal, but when all the other display objects have been removed. I have about 8 other objects… so my question is how do I detect their removal and incorporate it into my collision function? I hope this makes sense.
local goal = display.newImage("images2/goal3.png")
goal.x = 211
goal.y = 269
goal.myName = "goal"
physics.addBody(goal, { friction = .4, bounce = .2, density = 0, shape = goalShape} )
local star = display.newImage("images2/star.png")
star.x = 206
star.y = 87
star.myName = "star"
physics.addBody(star, { friction = .3, bounce = .3, shape = starShape} )
local function onCollision (self, event)
if self.myName == "goal" and event.other.myName=="star" then
local alert = native.showAlert( "\*\*\*\*\*", "Level Complete!",
{ "Next Level", "Replay" }, onComplete2 )
end
end
goal.collision = onCollision
goal:addEventListener("collision", goal)
[import]uid: 10355 topic_id: 8122 reply_id: 308122[/import]