local heli = display.newCircle(x_pos, y_pos, radius)
local y_direction = 1
local y_speed = 5
local function animate(event)
y_pos = y_pos + (y_direction * y_speed);
if(y_pos > screen_bottom - radius) then
y_direction = y_direction * -1;
heli.fill = green_paint;
end
if(y_pos < screen_top + radius) then
y_direction = y_direction * -1;
heli.fill = red_paint;
end
heli:translate( x_pos - heli.x, y_pos - heli.y )
end
local function touchpop(self, event)
if(event.phase == "began") then
self:removeSelf( )
end
return true
end
Runtime:addEventListener("enterFrame", animate);
heli.onTouch = touchpop
heli:addEventListener("touchpop", heli)
我试图在触摸时移除heli
对象。但是当我触摸它时它并没有消失。如何确保被触摸的物体消失?