Android 使用id:corona SDK调用transition.to
在我的一个corona应用程序中,我必须将转换应用于具有特定Android 使用id:corona SDK调用transition.to,android,transition,coronasdk,objectid,Android,Transition,Coronasdk,Objectid,在我的一个corona应用程序中,我必须将转换应用于具有特定id的对象。我该怎么做 local ball = display.newImage("ball.png") -- sample, actually there are random no. of balls created at an instant. ball.id = "ball_id" transition.to(ball,{time=200,x=400}) -- here, instead of ball, i
id
的对象。我该怎么做
local ball = display.newImage("ball.png")
-- sample, actually there are random no. of balls created at an instant.
ball.id = "ball_id"
transition.to(ball,{time=200,x=400})
-- here, instead of ball, i need to call all objects(if any) with id="ball_id"
任何建议都是值得欣赏的…您可以将所有对象存储在一个表中。
即使您要从球表中移除一些对象,此解决方案也会起作用。
它之所以有效,是因为我使用了ipairs。
更多信息:
local balls = {}
local function createRandonBall( id )
local ball = display.newImage("ball.png")
ball.id = id
balls[#balls + 1] = ball
end
local function animateBall(id)
for i, object in ipairs(balls) do
if(object.id == id) then
transition.to(object, {time=200,x=400} )
end
end
end
animateBall("ball_id") //call all objects(if any) with id="ball_id"