Sprites and selective transitions?

tecknerteckner Member Posts: 2
Hey people, I'm a very new developer-in both obj-c and gamesalad.
I was wondering if someone would tell me how I would go about doing this? I want to have one sprite to play, and if you drag/throw an object, a seperate random sprite (off a list) would start to play, then go back to the beginning after the second sprite is done playing.

I know it's alot to ask for with a newbie, but I'm shooting far...
Thanks
-Alex

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    yea teckner, a little more info would help. When you mean spritelist, what do you mean? Are you talking about the old sprites you'd find in older games? (it's been a long time since I've done any sort of game development).

    In order to do what I think you want to do, this is what I'd do:

    Have player 1 animated by default

    When you drag or throw that object, change an attribute you create to 1 (or something like that).

    While that attribute is 1, change the animation on player 1 to the new animation.

    Once the object is finished being dragged or thrown, change the attribute back to 0.

    and when that attribute is 0, have the player 1 resume it's original animation.

    You could do this with a few basic rules.

    Player1:
    RULE
    When attribute game.action = 1
    animate: (put the images for the 2nd animation here)
    OTHERWISE
    animate: (put the images for the original animation here)

    Object
    RULE
    when object receives touch
    change attribute game.action to 1
    OTHERWISE
    change attribute game.action to 0

    You could even create the object's rule on a timer, so when you touch it the attribute changes to 1, and then after say 2 seconds, switch the value back.

    anyways, that's how I'd do it.
  • tecknerteckner Member Posts: 2
    Well, I'll go a bit more in depth... I have one charactor kinda sitting there, moving around a little bit, which would be the first sprite (or gif, whatever would be easier because I'm using pixen) then if you drag and throw an object from a pile, and it hits the charactor, then a second sprite would play of the charactor being angry and reacting to getting hit. I was hoping I would be able to have the second sprite be one chosen randomly from a list (for the different possible reactions this charactor would have.)
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    yea, that's very possible, just tricky to wrap your head around.

    Using attributes is the easiest way in my opinion, just like tshirtbooth said above. You'll have an attribute that gets a random number when you pick the actor off the pile. When that actor hits the player, the player will play a certain animation based on what that value is. then reset all the values and start again.
Sign In or Register to comment.