Joystick and animation

MarkOnTheIronMarkOnTheIron Member Posts: 1,447
I finally managed to understand joystick behaviors thanks to codemonkey example.

Now I'd like to complicate it a little bit, I'd like to show a different sprite (and relative sprite animation if it moves) depending on joystick position.

Is it possible to do using angles? Something like:

if at angle 0 show spirit 0 and spirit animation 0
if at angle 45 show spirit 45 and spirit animation 45
and so on...

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Sure. Its pretty much the same as the setting the left and right images/animation tutorial.

    http://gamesalad.com/wiki/how_tos:gsc_move_stop_animate

    But instead of just left and right, you would use the angle given. See the DirectionalAnimation(demo) project I've added to the site.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Yes, something like the directional animation demo was what I was looking for.
    Then returning to the Joystick control demo you made I should be able to Create a constraint attribute to the stick 2 to return me a value between 0 and 8 (or higher if I divide for a number smaller than 45 right?) and then I use this value in a rule in the actor I want to move so that for every number I could trigger a different animation. Would it work? I'm far from my copy of GS and I can't test it.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    yep that should work.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Hi, I was trying to tweak a little the joystick demo in order to eliminate the second stick and have the ball move and rotate with only the first (the green one).

    I managed to have the ball rotate by changing the attribute rotate to game.angle1 but when it start moving now it doesn't stop even if I release the joystick.

    Here is an image of the green stick behaviors:
    http://img22.imageshack.us/img22/5779/joystick1.png

    I will be grateful for any suggestion
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    I don't think you need to modify the green stick behavior. Its just how you interpret the data it gives you on the moving actor. And that data is just the position of green dot. Combine that with the base position, you have 2 sets of coordinates.

    If you download it again, there is a scene for just one thumbstick with rotation as well.
    http://gamesalad.com/game/play/22929
Sign In or Register to comment.