Zooming and launch angles

KrakenCMTKrakenCMT Member Posts: 22
edited November -1 in Working with GS (Mac)
I'm not sure how the math is supposed to work on this, but I have a game with a full size at 960T x 640W. You can press a button to zoom out then back in, but I want the main actor to be able to still move while zoomed out. When you click the main actor, an arrow points in the direction of the mouse indicating where the actor will go. Sort of like the tiny balls game. But when zoomed out to the full size of the scene, the arrow acts very wrong. I got the code working for the arrow with the large size of the scene by using a camera offset attribute, but when you zoom out, things go wrong again. The position of the arrow itself is fine, it's just not pointing to the mouse position. And the arrow seems to think that the main actor's position is twice the X and Y it's at currently (if it's outside the 480 x 320 area).

This is the code for the arrow.

When mouse clicks actor -

Constrain self.Position.X to ( game.Player1PositionX + game.Mouse.Position.X + game.CameraOffsetX )/2

Constrain self.Position.Y to ( game.Player1PositionY + game.Mouse.Position.Y + game.CameraOffsetY )/2

Constrain self.Rotation to vectorToAngle( game.Player1PositionX - game.CameraOffsetX - game.Mouse.Position.X, game.Player1PositionY - game.CameraOffsetY - game.Mouse.Position.Y )

Constrain self.Width to magnitude( game.Player1PositionX - game.CameraOffsetX- game.Mouse.Position.X , game.Player1PositionY - game.CameraOffsetY - game.Mouse.Position.Y)

Any ideas on where this is going wrong?

Comments

  • KrakenCMTKrakenCMT Member Posts: 22
    I spent all day yesterday researching on the forums here and working on this issue trying to figure it out, but I haven't made any real progress. Any help would be appreciated.

    If I can't figure it out, I'll just have to make do with constraining the game size to 480 X 320.
  • PhoticsPhotics Member Posts: 4,172
    The touch data has to be offset for the new camera size.
Sign In or Register to comment.