move to coordinates

GraybayGraybay Member Posts: 114
edited November -1 in Working with GS (Mac)
I am trying to make it so that when the player collects a coin, it flies up to the area in the HUD that is keeping track of the number of coins collected before disappearing.

I have tried a move to behavior and inputted the coordinates of the HUD element. Problem is, when the coins are touched, they fly to where the HUD element was at the beginning of the stage.

Anyone know how to account for the change? or have them fly to the coordinates of the screen rather than the world?

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Hey,

    Try interpolate behavior. Put all the coins where they will end up in the game, and write down their X and Y cords. Then, put them in the level where ever you wanted them, and use the interpolate behavior.

    e.g:
    Interpolate: self.Position.X to: 715
    Interpolate: self.Position.Y to: 196

    Hope this helped
  • GraybayGraybay Member Posts: 114
    Thank you guys for the quick response, I tried both and I am still stuck with the same problem. Even with interpolate, the coins fly to the position that the HUD element was at the start of the level.

    I guess the HUD elements coordinates never change since they are not on a scrollable layer. Do they have some kind of screen coordinates I could use instead of the world coordinates it was assigned?
  • GraybayGraybay Member Posts: 114
    Much thanks for the example. But your scene stays put in the starting area at all times. My game is a side scroller, thus the HUD travels thousands of pixels away from that starting position while the player is running around. The coins always want to head back to that initial spot at the start of the level.
  • GraybayGraybay Member Posts: 114
    The HUD is in a non scrollable layer. That is why the coordinates never change to where they are in the world I think.
  • GraybayGraybay Member Posts: 114
    I have uploaded an example to youtube:



    I used your solution that you first suggested for this uptimistik.

    As you can see, the coins are being interpolated to the x/y position of the HUD coin counter in the center where you will notice it counting up. But they are flying to the position where it was right at the start of the level. and since the HUD is non scrollable, the coordinates never change, they just stay at the beginning of the level.
  • GraybayGraybay Member Posts: 114
    I actually found a solution to this in another forum for anyone who is interested. This was posted by bsumpter:

    1) Create the HUDX and HUDY global variables as you suggested.
    2) Double click an item on the HUD layer and unlock (creating an instance). Constrain HUDX/Y globals to the (Camera.Origin.position.X/Y + game.Counter.position.X/Y). This puts the coordinates where they should be in relation to the camera to deliver the item to the HUD counter.
    3) Interpolate just as you suggested.

    And thank you uptimistik, I used your idea of shrinking the coins as they get to the destination combined with this solution. The results are better than I had in mind.
Sign In or Register to comment.