Hello!
i have an asteroid that should bounce then coming to screen edges so have small polygons there, then i try to use repeat until asteroid dies but can’t figure out why the simulator crashes? What am i doing wrong?
And i also wants the asteroid to rotate a little but what aint working it just rotates 200 degree then stops?
[code]
local spawnAsteroid = function()
if collectedStar then
collectedStar = false
local asteroid = display.newImage(“asteroid.png”, true)
asteroid.x = math.random(50,700)
asteroid.y = math.random(50,900)
print(asteroid.x)
physics.addBody( asteroid, { density = 1.0, friction = 0, bounce = 0.3, radius = 25 } )
repeat
asteroid:setLinearVelocity(200, 200)
asteroid:rotate(200)
until collectedStar == false
end
end
Runtime:addEventListener(“enterFrame”, spawnAsteroid)
local wallLeft = display.newRect(0,0,2, 1024)
physics.addBody( wallLeft, { density = 1.0, friction = 0.3, bounce = 1 } )
wallLeft.bodyType = “static”
local wallRight = display.newRect(766,0,2, 1024)
physics.addBody( wallRight, { density = 1.0, friction = 0.3, bounce = 1 } )
wallRight.bodyType = “static”
local wallUp = display.newRect(0,0,768, 2)
physics.addBody( wallUp, { density = 1.0, friction = 0.3, bounce = 1 } )
wallUp.bodyType = “static”
local wallDown = display.newRect(0,1022,768, 2)
physics.addBody( wallDown, { density = 1.0, friction = 0.3, bounce = 1 } )
wallDown.bodyType = “static”
Thanks in advance=) [import]uid: 90942 topic_id: 23187 reply_id: 323187[/import]