Movement Problem!

MagoNicolasMagoNicolas Member, PRO Posts: 2,090
edited November -1 in Working with GS (Mac)
Hello, Im having a big problem trying to figure out how to move an Image (Square 30x30) 30 pixel to any direction. I dont want to appear 30 pixels further, i want it to move from on position to the other (30 pixels further) and stop.
I tried a lot of different ways. When I try it with time, it didnt give me always the same movement.

Any Clue?

Thanks!

Comments

  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Use `interpolate` for timed movement OR change the x and/or y attribute to the value of the desired location.
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    Like barkbark said, use interpolate.

    For example:

    Interpolate self.position.x to 250
    -Duration 1

    Interpolate self.position.y to 200
    -Duration 1

    This will move your actor to the specified x and y position and it will complete this move in 1 second. The duration is a real number so you can also make it something like 0.5 or 1.2. Play with this number to get the EXACT speed you want!

    Interpolate can be used in MANY different ways! It is a powerful behavior!
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Wow! Thanks! Didnt realize the Power of Interpolete! I Only use it for alpha in images!

    Thanks!
  • quantumsheepquantumsheep Member Posts: 8,188
    Interpolate is the new black.

    It's just made of awesome :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Except where collisions are concerned...then it's grey.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Actually interpolate has a cool feature in regards to collision. It seems to work to use interpolate as a way to make the collision area of an actor different from the size of an actor. So if I want a 30pixel diameter circle to have a collision area of 20 pixels. I can set the size of the actor to 20by20 and the collision area to circle and then put an interpolate behavior to very quickly change the width and height to 30. Now my actor looks like a 30 pixel diameter circle but the outer 5 pixels (5 on both sides of the diameter) should not respond to collisions.

    i think...

    :)
  • design219design219 Member Posts: 2,273
    scitunes said:
    ... use interpolate as a way to make the collision area of an actor different from the size of an actor. ...i think...

    Whoa, are you serious? I'm at work and can't test that, but if that true, it would be a great help.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    @scitunes, I think I should clarify my earlier statement...Using interpolate to modify position screws up collisions.

    If what you are saying is correct, that would be a cool, albeit partial, workaround for images with glow or shadows.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    It seems to work, but I need to test it further. It may be that it only works WHILE in the process of interpolating - I'm not sure yet.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Hmm...GS just needs a separate set of attributes for collision size, x and y.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Im Having Another problem.

    If I Click the Button Up twise it doesn`t wait to finish the first movement.
    I Make a button, When i touch it it change Atribute to 1.
    When 1, actors move up 30 pixels with interpolate.
    But if I press twise, it doesnt move fine.

    Any suggestion?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    try this:

    use a move to behavior for each direction. To move right put 30 for X and 0 for Y and switch it to actor. For left put -30 for X and 0 for Y. Same idea for up and down but with the Y instead of the X. Should work.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Yes, the problem is when i touch twise to button to the same direction.
    It doesnt wait for the completition of first movement.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I started writing a set of platformer tutorials here:
    http://gamesalad.com/wiki/how_tos:platformer_tutorials

    The first one deals with moving a player left and right, you can easily change it to be up and down or whatever you need.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Thx Firemaplegames, I already follow that tutorial.
    I need a movement of 30 pixels each time I press Up. And the movement should last some time ( I do that with interploate)

    The problem is that If I press 2 tiemes, it doesnt wait to finish the first movement.
    Please Help.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    create a self.boolean attribute, call it "moving", that is set to true once the first touch occurs. then set it back to false when the movement is complete. In rule that checks for a touch add a condition that requires `self.moving = false`

    Edit: FMG got this one...I was thinking movement occurred when the moving actor was clicked...but that is just dumb! ;-)
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to create a global boolean attribute called something like 'busy'.

    Only allow the player to move when busy is false.

    As soon as you hit the move key, set busy to true
    Then have a Timer that sets it back to false.

    Like this:

    Rule
    When all conditions are valid
    game.busy = false
    -----Change Attribute: game.busy To: true
    -----Interpolate
    -----Timer After [same amount of time as Interpolate] Run To Completion true
    ----------Change Attribute: game.busy To: false

    EDIT: barkbark beat me to it. But yes, same concept. I always have a 'busy' flag in my games. I use it all over the place to prevent the user from clicking or tapping when they aren't allowed. I put it on all buttons, and during all transitions. It prevents bugs from people tapping too fast.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Yeah, Thanks, I try that, dont know why it didnt Work... Will try again, Thanks,
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Finally I Made it, thanks to all, Interploate + Something Like Buzy solved My problem.

    Now i have another problem reletades to the same thing.

    Will Ask for help later!

    Im tring to make a game where you move in tiles (with interpolate) And there will be walls and items.

    Any tutorial in gamesalad that use my tipe of movement?

    Thanks
    firemaplegames said:
    You need to create a global boolean attribute called something like 'busy'.

    Only allow the player to move when busy is false.

    As soon as you hit the move key, set busy to true
    Then have a Timer that sets it back to false.

    Like this:

    Rule
    When all conditions are valid
    game.busy = false
    -----Change Attribute: game.busy To: true
    -----Interpolate
    -----Timer After [same amount of time as Interpolate] Run To Completion true
    ----------Change Attribute: game.busy To: false

    EDIT: barkbark beat me to it. But yes, same concept. I always have a 'busy' flag in my games. I use it all over the place to prevent the user from clicking or tapping when they aren't allowed. I put it on all buttons, and during all transitions. It prevents bugs from people tapping too fast.

  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    This is the Game Im starting ( Just made the movement And Walls)
    http://gamesalad.com/game/play/61487

    Want to Make The Player to move by tiles within a Maze of Walls.
    Please Help.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    If you are using interpolate you may have some issues with collisions. I think this is what is causing the issues with the walls. I think you may need to use move to or move. Then you should be able to just use a collide behavior.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Any Clue on how to make My tipe of movement with move? or move to?

    Thanks
Sign In or Register to comment.