Tracking Camera & Mouse Position on the Y...very close! Need a bit of help

TouchTiltGamesTouchTiltGames Member Posts: 1,162
edited November -1 in Working with GS (Mac)
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

Comments

  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Anyone might have a moment to offer a suggestion on this? Thanks a lot. :D
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I'm wondering if maybe you are making this too hard. Couldn't you have two versions of the target with the same image? One with constraining rules and one that is nonmoving. Then have the nonmoving target spawned at the target X and Y.

    just a thought
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Hey Sci, I do tend to over analyze things! Hehe.

    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.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    when the first actor is at the correct spot just have a spawn actor behavior and set the x and y in the spawn behavior to 0 to actor.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Do you mean on the spawned target:

    self.positionx to game.target
    self.positiony to game.target

    (assuming target is the first actor)
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Sorry you meant the position x and y on the spawn actor.

    so position x would be 0 and position y would be to a spawned actor attribute?
Sign In or Register to comment.