Hey,
I’m having problem with code you’ll see:
[lua]local physics = require(“physics”)
physics.start()
–physics.setDrawMode(“hybrid”)
physics.setGravity(0,0)
local storyboard = require (“storyboard”)
local scene = storyboard.newScene()
function scene:createScene(e)
local screenGroup = self.view
function spawnOrb()
local orb = display.newImage(“orb.png”);
orb.x = 60; orb.y = 400
physics.addBody(orb, “dynamic”)
end
end
function touchOrb(e)
if e.phase == “began” then
print(“orb began”)
display.getCurrentStage():setFocus(orb)
elseif e.phase == “ended” then
timer.performWithDelay(0, spawnOrb, 1);
print(“orb ended”)
orb:applyLinearImpulse(((e.xStart - e.x)/2), ((e.yStart - e.y)/2), orb.x, orb.y)
display.getCurrentStage():setFocus(nil)
end
end[/lua]
the problem is that I want when I throw the orb, I want another orb to show instantly,
I used
[lua] timer.performWithDelay(0, spawnOrb, 1);
[/lua]
after the e.phase == “ended” then
but it doesn’t work.
please help.