Calling functions?

dshoedshoe Member Posts: 62
edited November -1 in Working with GS (Mac)
I've been programming using traditional methods for a couple years now so it's taking a bit to get use to visual development with Gamesalad and I would like to know if there was a way of making a function (lets say that checks how many enemies are left and decide if it needs to spawn a new one) and being able to call it whenever. It seems like this would be making your own behavior but it doesn't seem like I can do that. Another way I thought of working around this (though this doesn't seem practical) is to spawn an actor that does what I need and destroying it at the end of the behaviors, and spawning it again when I want to use that function. I feel like I'm over complicating this :(

Comments

  • design219design219 Member Posts: 2,273
    I would think a global attribute (variable) "enemie count" would be the way to go. When and enemie is destroyed, subtract from the attribute. You would have a behavior on whatever actor you need effected by this count to have a behavior like "if attribute 'enemie count' = 0, do whaterver".

    Is that what you mean?
  • design219design219 Member Posts: 2,273
    Oh, you need a spawning actor, an invisible actor with just rules to spawn new eneimes: If attribute "enemie count" is < 4, spawn actor of type "enemie".
  • dshoedshoe Member Posts: 62
    Thanks I have it working how I like! I was closer than I anticipated. Though I think this is a feature that Gamesalad should work on, functions (voids in ObjC) can be very important and useful in programming and I believe the option to create your own behaviors would be great.
  • ORBZORBZ Member Posts: 1,304
    I've used self destructing invisible actor code blocks to reuse some logic that is only used occasionally.

    Spawn the code block actor when you need it to evaluate some globals. Then have it self destruct when it's done. Don't do this tightly looped. Do this on occasion.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Wow ORBZ. That's slick! I would have never though of that!

    Next you'll tell us you've devised a method for making GameSalad Object Oriented! lol
  • ORBZORBZ Member Posts: 1,304
    GS is object orientedish. It just lacks proper inheritance and message passing. Hint hint Gendai.
  • dshoedshoe Member Posts: 62
    That's what I ended up doing ORBZ, but thanks ;)
Sign In or Register to comment.