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 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
I really need you to help me in one thing that im really dying to understand. 1st, how did you define the DX,DY,GRAV as properties for the flyingBird object. they even are just parameters. I know you may say this is a silly question.
Thanks again
I have a shotgun object displayed on the screen, I was able to apply the setDrag feture using the movieclip. I would like to move this object around it self via touch/button to acconadate the sniping method. I’m wondering how to mice this object around it self. In addition, I want to apply a bullet ti be fired once the touch is applied to through a bullet to the desired bird/object
I’m facing problems on moving the gun to point to the moving birds. I’m wondering how this could be done [import]uid: 11038 topic_id: 3774 reply_id: 11494[/import]
What I’m trying to do here is i’m displaying a shotgun on the screen. I want to move the shotgun around it self; meant by that if the user tries to drag the shotgun up it will move the it up to point to the bird to shot without moving the shotgun it self up. in addition, once the user clicks on fire (assuming a fire button is there), a bullet will be fired to shot the flying bird.
it doesnt really show how you intend to move the gun. it wouldnt rotate. but presumably you have a sprites of it tipping backwards and also switching sides from left to right? will it’s y position change or are you keeping it at the bottom?
are you going to calculate a 3D trajectory of the bullet to birds in the distance?
[import]uid: 6645 topic_id: 3774 reply_id: 11517[/import]
Yes i’m intending to keep the shotgun at the button with the ability to move the shotgun barrel to up as well. In addition I’m planning to calculate the 3D trajectory of the bullet to birds in the distance?
then determine how far away it is from the centre of the screen to decide which animation sprite to show. but for instance how will you shoot birds on the far left… if you drag the gun to the left, and it points to the right. then you can’t shoot the bird on the left. what is your gameplay?
maybe you should drag your crosshair to the bird and click to fire. you can do this twice. then click the gun to reload. then repeat dragging the crosshair again?
or maybe you can move the gun left right by dragging the bottom of the gun, and move the tip of the gun left/right by dragging the tip of the barrel.
Without knowing your gamplay mechanism I don’t know what to suggest. [import]uid: 6645 topic_id: 3774 reply_id: 11528[/import]
What I’m trying to do is moving the gun left right by dragging the bottom of the gun, with the ability to move the tip of the gun left/right by dragging the tip of the barrel. In the same time while moving the gun, the barrel will be moved and pointing to birds flying on the screen. Thereafter, the fire button would be pressed to down the targeted bird
[import]uid: 11038 topic_id: 3774 reply_id: 11542[/import]
how to control the shotgun, i mean to move it as i have described with the crosshair icon for targeting objects . [import]uid: 11038 topic_id: 3774 reply_id: 11553[/import]
event.x is the x-position in screen coordinates of the touch. event.y is the y-position in screen coordinates of the touch. event.xStart is the x-position of the touch from the “began” phase of the touch sequence. event.yStart is the y-position of the touch from the “began” phase of the touch sequence
actually i would probably use some invisible objects (red & green below) that covered the top and bottom parts of the gun to work out which was touched. but you will have to move these relative to your graphic as it moves. the maths for this really depends on the size of your gun graphic though and how it animates.
Yes but how could i move the object (the barrel part) up without moving the gun ti self. One more thing, how to draw the crosshair and to be joint to the gun (lets say 100px far from the gun) so it can move the gun and the crosshair in parallel.
You mean you want transform controls to distort the image? Because that seems like the only way to move the gun without moving the gun.
You have to draw the images for the gun in different positions, scale/rotate it, or use separated graphics that won’t look odd when moving independently. [import]uid: 11024 topic_id: 3774 reply_id: 11569[/import]