Only drag and drop One actor ? HELP?

JamieOneilJamieOneil Member Posts: 877
edited November -1 in Working with GS (Mac)
Ok i have thought of a way to recycle my actors.
When they are out the screen and you tap somewhere, i want that actor to move to the touch position.
BUT, there might be 5 of the same actor out of the screen waiting to be recycled, so how could i make it so that it only drag and drops one of the actors at a time??

thanks.

JamieOneil

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Here's a system that I use a lot. Create a game integer attribute called actorCount.

    In the recycled actor create an integer called selfID

    then in that actor do this:

    change game.actorCount to game.actorCount+1
    change self.selfID to game.actorCount

    What this does is automatically give each instance of this actor a unique ID number. The lowest one on the actor list under scene layers will get number one and it will count up from there.

    Then you can use this ID number in so many ways. For example you will probably want another game attribute (integer) called game.CurrectActor

    Then have a rule that says when mouse is down change game.CurrentActor to game.currentActor+1

    Then in the recycled actor have a rule that says when self.seflID=game.CurrentActor
    interpolate x to ????
    interpolate y to ????

    Now each time you click the next actor will go where you tell it to.
  • JamieOneilJamieOneil Member Posts: 877
    scitunes said:
    Here's a system that I use a lot. Create a game integer attribute called actorCount.

    In the recycled actor create an integer called selfID

    then in that actor do this:

    change game.actorCount to game.actorCount+1
    change self.selfID to game.actorCount

    What this does is automatically give each instance of this actor a unique ID number. The lowest one on the actor list under scene layers will get number one and it will count up from there.

    Then you can use this ID number in so many ways. For example you will probably want another game attribute (integer) called game.CurrectActor

    Then have a rule that says when mouse is down change game.CurrentActor to game.currentActor+1

    Then in the recycled actor have a rule that says when self.seflID=game.CurrentActor
    interpolate x to ????
    interpolate y to ????

    Now each time you click the next actor will go where you tell it to.

    Thanks for the reply.
    But is there a video tutorial or something anywhere.
    Im still a bit confused.

    JamieOneil
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    ORBZ uses this system in his waypoint demo. You can search for it in the New section of the GS creator.
  • JamieOneilJamieOneil Member Posts: 877
    scitunes said:
    ORBZ uses this system in his waypoint demo. You can search for it in the New section of the GS creator.

    i'll try it, thanks!

    JamieOneil
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Another way to get the idea would be to start a new project.

    Create one actor and do this:

    Create a game integer attribute called actorCount.

    In the actor create an integer called selfID

    then in that actor do this:

    change game.actorCount to game.actorCount+1
    change self.selfID to game.actorCount
    display text self.ID

    Then drag a few of these actors into the scene and preview. This will show you the unique ID on each actor.
  • JamieOneilJamieOneil Member Posts: 877
    scitunes said:
    Another way to get the idea would be to start a new project.

    Create one actor and do this:

    Create a game integer attribute called actorCount.

    In the actor create an integer called selfID

    then in that actor do this:

    change game.actorCount to game.actorCount+1
    change self.selfID to game.actorCount
    display text self.ID

    Then drag a few of these actors into the scene and preview. This will show you the unique ID on each actor.

    thats what i have done.
    And i have been able to put it in my app.
    It works great!
    thanks very much for your help.

    JamieOneil
  • RHRH Member Posts: 1,079
    heh, I never saw that ORBZ example ever. I have something exactly the same on my page.

    http://gamesalad.com/game/3279 :)
Sign In or Register to comment.