Spawning Actor Reference?

Is there a way to spawn an actor on stage, and maintain a reference for later alterations?

Answers

  • WingmanappsWingmanapps Member Posts: 458
    Create a new game.real.attribute called "Spawn Point"

    On your spawned actor
    Change game.attribute.spawn point to self.position.x
    Change game.attribute.spawn point to self.position.y
  • BoomshackBarryBoomshackBarry Member Posts: 712
    Or if you'll need multiple versions of the same actor, change the game attribute to an actor attribute, and then each actor can reference it's own starting point, if that's what's needed.
  • drtyrelldrtyrell Member Posts: 3
    Thank you, that's a great start. What about a reference to the Actor like an attribute that could hold Actor itself...so that I could something like this:

    game.actor.attribute = self
  • WingmanappsWingmanapps Member Posts: 458
    that is exactly what boonshackberry wrote - When creating self attributes. It only effects that instance and not the prototypes
  • BoomshackBarryBoomshackBarry Member Posts: 712
    edited June 2013
    boonshackberry
    Haha kind of close!

    I understand what you mean @drtyrell, you want to reference the actor itself, not it's coordinates. The method you posted of storing a reference to an actor inside a variable doesn't work in Gamesalad as it does in many programming languages, although it would be handy.

    I think off the top of my head I'd have a global attribute to count how may actors have been spawned. Inside each actor set the first behaviour to change self.id to global.count, and then increment global.count by 1.

    That would give each instance it's own id number, which could be used to reference it by. It's still tricky though as actors can't reference each other's attributes unless they're unlocked on the same scene, so you'd probably have to keep a lot of the logic inside each actor itself, referencing it's own id number. So instead of an external actor being able to call a specific instance id, you'd have duplicate logic inside each actor checking it's own id.

    That's off the top of my head, but that's old school Gamesalad thinking, there might actually be a better method using tables to store the ids instead so that they can be referenced from anywhere.
  • WingmanappsWingmanapps Member Posts: 458
    edited June 2013
    boonshackberry
    Haha kind of close!

    WHOOOOOPS!!! I blame autocorrect :-S
  • drtyrelldrtyrell Member Posts: 3
    Okay, I think you two have answered my question. I have a book on GameSalad for iOS and haven't seen a single instance of what I'm talking about. The attribute types don't seem to include a type of Actor, which would solve the problem instantly.

    I want to create some generic methods of transitioning between scenes by spawning rects on top, interpolating the alpha to 1 from 0 then switching scenes. Without things being dynamic, the Change Scene value is hard coded, and not able to reference a global attribute.

    My friends are using single scenes and recommending I don't change, but without traditional mechanism this seems massively tedious. :(
Sign In or Register to comment.