Changing Actor Number When Another Deleted

robert.mccarthyrobert.mccarthy Member Posts: 165
edited March 2012 in Working with GS (Mac)
Hi All,

Right, I currently have an Actor and when this actor is spawned it gets given a number. If I then spawn the same actor again (so 2 on screen) this new actor will be given a number which is +1 of the previous actor. So....:

Actor 1 self.myNumber=1
Actor 2 self.myNumber=2
Actor 3 self.myNumber=3
Actor 4 self.myNumber=4
Actor 5 self.myNumber=5

These numbers are assigned from a global counter (spawnNumber) which when an actor is spawned adds one to it, then assigns the number to itself to give it is unique sequential number....SIMPLE SO FAR :)

What I want to do is, when an actor is destroyed from the scene, I want the global 'spawnNumber' (this I can do) and self.myNumber to reduce by 1 BUT only if the self.myNumber of the actor is above the spawn number.

So, if I have the above actors on scene and delete Actor 3, then Actor 1 & Actor 2 do not change their self.myNumbers but Actor 4 & Actor 5 reduce.

This is so that I always have a sequential string of numbers within my actors :)

I hope this makes sense.

Comments

  • robert.mccarthyrobert.mccarthy Member Posts: 165
    Right, what I have done to is (combination of what you said):

    On Actor:

    if self.myNumber >= game.destroyedactor {
    change attribute game.destroyedactor to self.mynumber

    timer after 2.seconds
    change attribute game.destroyedactor to 100000
    }

    I had to start game.destroyedactor at a high number when starting the scene, as if it was 0 then the rule would instantly come into effect for all actors. This was because nothing had yet been deleted, so it was 0, and all the actors numbers would be higher than it.

    I have another issue now, but this is one step forward thanks :)
    (although it seems I go 1 forward and about 5 backwards :( )

    Cheers
Sign In or Register to comment.