Im new in Corona, im trying to move birds (y-cordination), from let to right of the screen (one after the other).
The problem is i don’t know how to set different listeners for different objects; currently, within the provided code, once the second object is shown, the first object stops and the second keeps moving.
Im trying to show birds every one second using the Movie Clip library and then I want to move every bird individually from left to right without stopping the other birds till the bird disappears (left the screen from the right side)
local flyingBird
local dx, dy, grav = {},{},{}
local birdsCounter = 0
local physics = require “physics”
local movieclip = require(“movieclip”)
require “sprite”
display.setStatusBar (display.HiddenStatusBar)
local localGroup = display.newGroup()
local objectBackground = display.newImage(“images/background.png”)
localGroup:insert(objectBackground)
function createBirdObject()
birdsCounter = birdsCounter + 1
flyingBird = movieclip.newAnim(12,{“images/bird/1.png”, “images/bird/2.png”,“images/bird/3.png”})
local random = math.random
flyingBird.x = 100
flyingBird.y = 75
flyingBird.xScale = .4
flyingBird.yScale = .4
flyingBird:play()
dx[birdsCounter] = 2
dy[birdsCounter] = 3
grav[birdsCounter] = 0.0
localGroup:insert( flyingBird )
Runtime:addEventListener( “enterFrame”, moveSprite )
end
– Function to move every bird around screen
function moveSprite( event )
local bird = event.target
bird.x = bird.x + dx[birdsCounter]
if ((bird.x < 30) or (bird.x > 80)) then
dy[birdsCounter] = - dy[birdsCounter] - grav[birdsCounter] – i used [birdsCounter] this to set the default parameters for each new object
end
dy[birdsCounter] = dy[birdsCounter] + grav[birdsCounter]
end
local createNewBirdEveryoneSecond = timer.performWithDelay( 2000, createBirdObject, 2 )
[import]uid: 11038 topic_id: 3774 reply_id: 303774[/import]

[import]uid: 6645 topic_id: 3774 reply_id: 11550[/import]
[import]uid: 11038 topic_id: 3774 reply_id: 11553[/import]
[import]uid: 6645 topic_id: 3774 reply_id: 11554[/import]