Tracking Camera & Mouse Position on the Y...very close! Need a bit of help
TouchTiltGames
Member Posts: 1,162
Ok I'm really close to getting this..I just need some help with one small issue.
I have my target graphic following the mouse and as I go up the screen in my 1024x1024 scene (a vertical world), past the camera area, the camera follows the target and then I shoot. Only in my other world, where the scene was simply 1024x768 after I shot it left the target there so you know where you shot last. That works great.
So I have two issues: 1) I can't get the target to stay there after I shoot in my vertical world AND 2) When I press down to shoot the 2nd time, the target is gone. Here's my code:
----On the Main Target-----
Constrain: game.targetx To: scene.Camera.Origin.X
Constrain: game.targety To: scene.Camera.Origin.Y
Rule
When game.target = 1
self.position.x To: game.Mouse.Position.X + game.target.X
self.position.x To: game.Mouse.Position.X + game.target.Y
Control Camera
----On the Target after you shoot----
Rule
game.target = 0
*change attribute: self.position.x To: game.targetX
*change attribute: self.position.y To: game.targetY
Both the target that is constrained to the mouse and the target that stays where you shoot after you let go are on scrollable layers
Where I have asterisks is where I know I (probably?) have to change it to tell the camera and your position where you pressed up (shot) afterwards..but I've been trying and it's not working.
Cheers,
Shane
I have my target graphic following the mouse and as I go up the screen in my 1024x1024 scene (a vertical world), past the camera area, the camera follows the target and then I shoot. Only in my other world, where the scene was simply 1024x768 after I shot it left the target there so you know where you shot last. That works great.
So I have two issues: 1) I can't get the target to stay there after I shoot in my vertical world AND 2) When I press down to shoot the 2nd time, the target is gone. Here's my code:
----On the Main Target-----
Constrain: game.targetx To: scene.Camera.Origin.X
Constrain: game.targety To: scene.Camera.Origin.Y
Rule
When game.target = 1
self.position.x To: game.Mouse.Position.X + game.target.X
self.position.x To: game.Mouse.Position.X + game.target.Y
Control Camera
----On the Target after you shoot----
Rule
game.target = 0
*change attribute: self.position.x To: game.targetX
*change attribute: self.position.y To: game.targetY
Both the target that is constrained to the mouse and the target that stays where you shoot after you let go are on scrollable layers
Where I have asterisks is where I know I (probably?) have to change it to tell the camera and your position where you pressed up (shot) afterwards..but I've been trying and it's not working.
Cheers,
Shane
Comments
just a thought
Yeah it is the same image, 2 different actors.
"Then have the nonmoving target spawned at the target X and Y."
That is my issue, how do I spawn it in the place where the moving one was given the above code? It will work on my previous levels where the scene doesn't scroll.
self.positionx to game.target
self.positiony to game.target
(assuming target is the first actor)
so position x would be 0 and position y would be to a spawned actor attribute?