Multiple Animation Sequences and Interactions

adobson66adobson66 Member Posts: 11
Hey everyone I'm relatively new to this program. A long time ago I made a small PC Desktop program that let an animated character walk around and do random things. You could click on him and he'd do different animations and stuff.

I'm not very good at programing complex gameplay, so I thought it would be easy to translate my character into an iphone/ipod touch "game." And coincidentally all of his original sprites just happen to fit the size constraints perfectly.

The problem I am having is that I don't know what the best way would be to work out his animation sequences. He needs to be able to randomly pick an animation after a short period of time if you don't touch him to make him feel alive. He also can't be allowed to go into another animation if you've already got one going.

What I've been able to do right now is make each separate animation it's own "actor" and when you touch the screen it spawns the new actor and deletes the old. And when the new actor ends it's animation (via a timer) it deletes itself and respawns the old actor. This works great if you're just going from one animation to another, but not so for randomly picking an animation upon touching.

Thus far I have 2 animations for when you touch him but it's finicky for which one it'll pick. You can view what I've got done here: http://gamesalad.com/game/play/65221

Ps: For some reason even in Safari I can't get this thing to play properly, so I hope everyone else can.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Nice cartoon style animation, adobson66, looks professional to me! My first thought reading through your post is that you shouldn't need a different actor for each different animation sequence (if i've understood you correctly). I'm guessing, for more than one animation "choice", your already using Random; the result updating a scene/game attribute, each number triggering a different sequence. This can all be done in the one actor, no need for more; no need for spawning.

    To summarize, depending on the random number chosen (or a fixed order of numbers in an attribute) then: when random/attribute is such and such, run a particular Animation Behaviour sequence.

    Hope that helps.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    I understand the concept of the randomizing, but I don't know how to physically implement it into the game. Thus far I have succeeded in only using drag-drop code and not actually writing variables and stuff like that.

    While I understand the value of having everything contained in one simple actor, the end result is that there's only ever going to be one character on the screen and nothing else. By breaking up the animation into multiple actors I can control how each of those behave properly and it boils down to simple "if" "then" statements.

    Like I mentioned before, I'm not very good at programing right now and it seems like it would be rather hard for me to not only program it to play certain animations that lead into others but also switching between "allow touch" to "not allow touch" within those animations. By having separate actors I can designate from the start if touching will or will not do anything for each specific animation. Yes it ends up having a TON of actors in the end, but I'm comfortable with that for right now.

    I guess what I'm looking for is what can I do for the initial "standing" animation to allow it to randomly spawn an actor at a random time? That's the piece of code that I don't know how to do.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    adobson66 said:
    While I understand the value of having everything contained in one simple actor, the end result is that there's only ever going to be one character on the screen and nothing else. I ought that's what's required, one actor moving different ways. By breaking up the animation into multiple actors I can control how each of those behave properly and it boils down to simple "if" "then" statements.

    Don't quite understand when you say there's only going to be one character on the screen and nothing else, as if that's a worry.... If there's one character that randomly animates every time its pressed, its still one character. Spawning is useful for creating new occurences of an actor, and 99% of the time, to inherit all of its parents attributes/scripting.

    The simple if/then statements would still all be simple in the one Actor. They'd all be in the one Rules list, although the list could turn out quite long though! But at least it'd be easier to tweak/amend/add to, etc.

    Random spawning is no problem, but with respect, from your description and upload of what you're trying to do, you don't need spawning at all. A spawned actor, although it can be used as such, is hardly ever used to replace the actor that spawned it. Rather, it appears as an extra actor.

    Anyhow, if I've not misunderstood completely, perhaps try the following?:

    Create a scene (always safer) integer attribute called, say, SequChoice.

    In your Rules, put when mouse or touch is down/pressed, change attribute SequChoice to random(1,5)... 5 being an example of the maximum number of sequences you have.

    Then 5 rules follow: when attribute SequChoice = 1, then put the Animate Behaviour sequence you want, then etcetera up to 5.

    That should work out OK, all in the 1 actor.
    Hope it helps.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    Thank you, gyroscope, for that information. I've been able to add the random integer to the "game" so that whenever you click on him he performs a different animation. I've got 3 animations added right now.

    On top of that I've been able to add a timer. After 5 seconds of waiting, Janus will perform one of the 3 animations randomly on his own accord. And to keep things clean, I've been able to group everything together so I know what's part of the timer and what's part of the touch activation. I've updated the game online so you can all see how it looks now.

    But now I've got a serious question. After letting him do his thing for a while, the game began to severely slow down until it eventually just stopped running. Is this a problem on my end? Does anyone else experience this? I'm worried that with all the animation the game might start to creep up in size and I want to keep this as simple as possible.

    I can't view the game online for some reason even in Safari, so if someone could take a peek and check it out and give me some feedback on how it works, It would be very much appreciated.

    http://gamesalad.com/game/play/65221

    Thanks!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hmm, see what you mean. Unless I'm mistaken (and perhaps one of the other more experienced forum members will correct me if I'm wrong), the slowing down shouldn't have to do with the amount of animations you have; it's only 3, after all. Plus it works fine for a while, which leads me to think there is a buffering problem; it's somehow getting "clogged up" as it were. Or there's some other coding that's causing the slow down... maybe next time you upload it you'll allow downloads so we can see what's going on in the Rules?

    I wonder if it's worth temporarily deleting the Timer for the while, and see if it still slows down? That way, you'll know what causing the data jam; then perhaps it can be solved a different way.

    Have you any other Rules other than the click + Timer ones? There could be something there upsetting it. (Oh, I've just written that)...or it could be a bug. Or...OK, I've run out of ors.... :-)

    Seriously, I'd be interested in knowing if deleting the Timer solves the prob for the while.

    ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    Oops. Sorry about that. i forgot to check that little button when I published it. I just updated it so you can download it now.

    I'm still really new at this so writing the code is still very challenging for me. If you have any suggestions or tips, It might help to explain it to me like I'm a 4 year old. lol. Although honestly I'm amazed I was able to pick up THIS much as it is! lol
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    No worries, adobson66, everyone learns at different paces! (Plus learning different things at different times). GS is like many other programs, when there are the "Ah, I get it!" moments. That's good when that happens.

    The more I think about, the more I think the Timer is the problem; and I might know a "safer" way to get that aspect working. We wait to see...OK, off to download your gamefile and take a look.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    I've made a revised version of your game file, deleting all of the actors that you used for spawning, and put all of the click animations in the one actor. I'm sure you'll see how straightforward this is.

    As for the random animations after five seconds of no clicks, I've done a few tests but haven't yet managed to make it work successfully. I'll hopefully nail that one tomorrow some time for you.

    In the meantime, i'll upload the revised so far for you to look at the Rules, to see what you think.

    :-)

    http://gamesalad.com/game/play/65294

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    I think you're right, it is the timer. I deleted it and tested it out and it works just fine. But I really do need to have a timer eventually because I want him to do stuff even if you don't touch him... that's what makes him feel alive.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Hey, I think I can get it to work gyro... unfortunately the shared server is down... And when I right click on download project it just opens the game in full screen... I've always just used the shared link in GS... So any tips on how to download it?

    Edit: I think I can get it to work... Just need to download the project. :D
  • adobson66adobson66 Member Posts: 11
    I just tried to download it and it came up as a "chess" file and I can't open it in GameSalad... @_@
  • chosenonestudioschosenonestudios Member Posts: 1,714
    If you wanna email it to me, I'll take a look :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    adobson66 said:
    I just tried to download it and it came up as a "chess" file and I can't open it in GameSalad... @_@

    all downloads look like Chess! (And even open as Chess before crashing). That confused me, for a while. All you have to do is click on it to change the extension to .zip. Then double click to expand; you'll have your game file then.
    chosenonestudios said:
    Hey, I think I can get it to work gyro...

    That'd be great if you could sort the Timer, thanks! (yet again, gone 2 here in the UK and I should be asleep...)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    Seems to be some server issues... this page isn't refreshing well either...

    chosenonestudios, I don't know what file I need to send and also gyroscope has already done some work on it (which I don't have yet) so I dunno what I should do. They seem to know exactly what needs to be done, it's just getting it to work for download so I can see it myself and fix it and stuff...
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Yea, I just cant download it.... When I click download project it just opens the game up in full screen :/
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Edit: Just downloaded it (Thanks Gyro) Will take a look :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    chosenonestudios said:
    Yea, I just cant download it.... When I click download project it just opens the game up in full screen :/

    try ctrl click, that'll do it. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • chosenonestudioschosenonestudios Member Posts: 1,714
    Ok it just crashes GS :/
  • chosenonestudioschosenonestudios Member Posts: 1,714
    gyroscope said:
    all downloads look like Chess! (And even open as Chess before crashing). That confused me, for a while. All you have to do is click on it to change the extension to .zip. Then double click to expand; you'll have your game file then.

    Nvm missed this... (I just converted it straight to a .gameproj) Alright now looking! :D
  • adobson66adobson66 Member Posts: 11
    Ok, I just downloaded the changes and that's the same issues I was having when I started making the game. The problem is that while the animation is playing, touching shouldn't be allowed otherwise it just starts playing a new animation right in the middle of the current one.

    That's why I was breaking things up into actors because then I could say "this actor doesn't do anything if you touch it" or "this actor DOES do something if you touch it" whenever I wanted. It allowed me more control over the various elements because there are going to be instances where he'll start an animation, and if you touch him during that specific one, he'll play a different one, but if you don't he'll just go back to the first animation.

    Does that make sense? I know it's convenient and logical to have them all in one actor. I have made some video games before and I know getting the actor to do everything you need them to do is vital to programing. But this is kinda a special case I think... I dunno...

    I think at this point I prefer the multiple actor method. I just need to find a way to make it so it'll randomly play an animation on it's own if I don't touch it.

    I really do appreciate the help though. Every step of the way I learn a bit more.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Ah, forgot to mention that, about it running to the end of each animation sequence, ignoring any other clicks while it does; I haven't solved it yet.

    That has to be solvable somehow within the one actor though, I'm 99% certain. Although that doesn't help you if I can't think of anything at the moment...

    I'll work on your file tomorrow now, (I mean today!) and see what I can come up with. Maybe another member might solve it first anyhow.

    :-)

    Edit: alternatively, stick with your spawning way (I thought there was a more straightforward way, but i see now that it doesn't immediately solve the click while animating problem; and we'll all have a bash at fixing the Timer. Sorry to mislead you (half of this is trying to think in the early hours of the morning; not good...)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Rob2Rob2 Member Posts: 2,402
    yeahh...downloading for the rest of us....zip zap chess... wtf.. should have been sorted months ago its a 20 minute job.
  • adobson66adobson66 Member Posts: 11
    Well, I updated it with more animation choices now. I think around 6 total thus far... I'm getting to the point where it's almost got all the animations it originally had, but now needs to start doing the interactive on it's own thing...

    There's gonna be several branching trees of animation choices down the road. Sometimes if you tap him at the right time during an animation he'll do a different action. Somehow I have to work out why the timer won't work for this. Whenever I have the timer running it goes very slow and usually crashes. Take the timer out and it's fine.

    Now I'm new to this but could the cause of it be because of the checked box "run to completion"? or something along those lines?
  • adobson66adobson66 Member Posts: 11
    so um... does anyone know why the timer crashes the game if left to it's own devices? Anyone?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Whoops, I for one said I'd have a bash at that, but...forgot, sorry about that. I'll get onto it later today, see if I have any success.

    "Clears throat, official voice": I'd like to take this opportunity to apologise to Adobson66 for my misguided advice concerning to not use spawns for each animation, telling him that it should all work nicely in one actor. Having spent several hours trying different things, I realise the folly of my way, as I couldn't get the "after 5 seconds, do its own thing" to work. I will whip myself immediately; thank you. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Joking aside, I found this recently, by Mike Quinn, might help you out:

    http://gamesalad.com/game/play/37013

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • chosenonestudioschosenonestudios Member Posts: 1,714
    gyroscope said:
    Whoops, I for one said I'd have a bash at that, but...forgot, sorry about that. I'll get onto it later today, see if I have any success.

    "Clears throat, official voice": I'd like to take this opportunity to apologise to Adobson66 for my misguided advice concerning to not use spawns for each animation, telling him that it should all work nicely in one actor. Having spent several hours trying different things, I realise the folly of my way, as I couldn't get the "after 5 seconds, do its own thing" to work. I will whip myself immediately; thank you. :-)

    Totally forgot about this.... Just a heads up, I got the after 5sec thing to work (in one actor) the problem I had with the one actor was if you clicked on it while it was doing the after 5s rule it would overwrite it... So I never uploaded it...

    But if you want me to download your newest release I'll update with the after 5s thing working... Lemme know :)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    chosenonestudios said:
    Totally forgot about this....

    Yeah, totally forget about that, "read between the lines" and you'll find that Chosenone is the main man.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • adobson66adobson66 Member Posts: 11
    Basically the only thing I have to do to make the "automated" method work is to copy all of the touch commands and just put them in a timer. When the timer reaches 5 seconds, it randomly picks a number and plays an animation.

    That's what I had before and it worked for a while, but after a couple of animations it started to get boggled down and slow and eventually would crash. Like I mentioned before, is there possibly a checked box that I have that I shouldn't? Does having it set to "run to completion" checked make any difference? What does that box do anyway? When it deletes the actor and inserts the new one, shouldn't the original be reset back to 0, timer and all?
Sign In or Register to comment.