Spawning Random Actors in a Specific Location

DigitalDianaDigitalDiana Member Posts: 34
edited January 2012 in Working with GS (Mac)
Hello!
I have been having trouble spawning new actors in 2 particular locations (I have 2 sets/groups of actors for each location and they don't mix -- For example: one location for random numbers and one for random letters). I have my game set so that when the main menu scene changes to the game scene, 2 random actors (one from each set/group) automatically spawn in the 2 particular locations I have set up (1 for each of them -- I have these 2 particular locations through use of constrain attributes). Also, I have set up a rule so that when 2 particular actors are in each of the 2 locations at the same time, each of the 2 locations will spawn a new actor. It works fine, except for that it doesn't get rid of the first 2 previous actors at those locations. What do I do to get rid of the first 2 random actors so that the new 2 actors will spawn without the first 2 actors behind them?

Here is my set-up:
-------------------

Location A Actor:

Constrain Attribute: self.Position.X To: game.SpotX-46
Constrain Attribute: self.Position.Y To: game.SpotX-65

Rule: When game starts, spawn a random actor in this Location.
Attribute: game.PlayGame is true
-Constrain Attribute: RandomActorSlotA To: random(1,12)
-Rule: Attribute: game.RandomActorA = 1
Spawn Actor: Actor 1
Layer Order: Front of layer
Relative to: Scene
Position: game.SpotX-46 and game.SpotY-65

-Rule: Attribute: game.RandomActorA = 2
Spawn Actor: Actor 2
Layer Order: Front of layer
Relative to: Scene
Position: game.SpotX-46 and game.SpotY-65

(Continues all the way down to 12)

Location B Actor:

Constrain Attribute: self.Position.X To: game.SpotX+46
Constrain Attribute: self.Position.Y To: game.SpotX-65

Rule: When game starts, spawn a random actor in this Location.
Attribute: game.PlayGame is true
-Constrain Attribute: RandomActorSlotB To: random(0,11)
-Rule: Attribute: game.RandomActorB = 0
Spawn Actor: Actor A
Layer Order: Front of layer
Relative to: Scene
Position: game.SpotX+46 and game.SpotY-65

-Rule: Attribute: game.RandomActorB = 1
Spawn Actor: Actor B
Layer Order: Front of layer
Relative to: Scene
Position: game.SpotX+46 and game.SpotY-65

(And so on...)

Basically from here on, I have a Button Actor with a rule that says that if there are 2 particular actors in each location at the same time, then the Change rule kicks in. I have a boolean attribute called game.ChangeTime and it is supposed to spawn a new actor in each of the 2 locations, which it does, but it doesn't hide/remove the previous two actors in those spots.

Button Actor:

-Rule:
Attribute: game.RandomActorA = 12
Attribute: game.RandomActorB = 0

Change Attribute: game.ChangeTime To: 1

Then I have the exact same code as Location A Actor and Location B actor (because I simply copied the code within the same actor), but in place of game.PlayGame, I inserted game.ChangeTime and it works well, but again, it doesn't hide/get rid of the 2 previous actors.

What do I do?

Any help would greatly be appreciated! :)


Comments

  • DigitalDianaDigitalDiana Member Posts: 34
    Also, I want to keep using the same actors. I don't want them destroyed, just recycled so they can randomly be selected to sent to those locations.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Even though I think the whole recycle thing is now a moot point with apple leaving armv6 behind but there is a video here on recycling actors in the index select actors. http://gleesongroupmedia.com/gsguide/gsguide.html
  • DigitalDianaDigitalDiana Member Posts: 34
    edited January 2012
    Thanks for responding to me. :) I'll check out the video. Aside from recycling, what are alternatives for me?
  • calvin9403calvin9403 Member Posts: 3,186
    edited January 2012
    no @FBS recycle is still important when you have heavy images and gameplay

    @Diana if you just want to let them go away then change there alpha to zero and follow the video FBS post


    CAlvin

    EDIT: beat by T again
  • DigitalDianaDigitalDiana Member Posts: 34
    edited January 2012
    Thanks everyone for responding to my post!

    @FryingBaconStudios: I checked out the video, but it displays moving actors that spawn. My actors that spawn are stationary and stay in the particular locations.

    @tshirtbooth: I am trying to create a game where the player has to move the hands of a clock to the time that is displayed in a digital-like clock (ex. 12:05). Instead of using Display Text to display hours and minutes, I created images of the hours (1 through 12) and minutes (by 5's -- 00 through 55). I have the hands on the clock moveable to the player and a digital-like clock showing what time the player needs to set the clock to. Once the player has the clock hands in place, the player then clicks the "check" button, it tells the player if he/she is right. If the player is right, I have a rule that triggers the spawning of 2 new time actors (1 hour and 1 minute) in place of the previous two. Unfortunately, the first two actors don't disappear when the new two actors spawn forth.
    For example: The time displayed is 12:05, 12 is in Location A and 05 is in Location B. When the player correctly sets the hands of the clock in place and clicks on the Check button, 2 new actors would spawn (ex. 3 and 00) in place of actors 12 and 05 (3 would take place of 12 and 00 would take place of 05).
    I want new actors to spawn each time the player is correct.

    @calvin9403: I have already set up the spawning rule, but I'll look into the alpha to zero.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2012
    I do mostly iPad apps and I use spawn but maybe not as much as others, I haven't seen a drag in resources on my ipad2. Although, I imagine the size of the spawning actor plays into it but in my tank game I spawn lots of bullets and haven't seen a major effect. Okay, so an ipad2 has 512Mb of ram that's the same amount as an xbox360 and the processor is faster so I still say for ipad2 it's not an issue. I'm not much for iPhone games not enough realestate for my ideas.
  • MotherHooseMotherHoose Member Posts: 2,456
    okay I will give this a try!

    gameAttribute index-type timeIsCorrect =0

    on the prototype handActors:
    Rule: when
    Attribute: game.timeIsCorrect = 1
    --Destroy this actor

    on the Button to √:
    in the rule for checking if Player has it right … add::
    --changeAttribute: game.TimeIsCorrect To: 1

    newRule: when
    Attribute: game.TimeIsCorrect = 1
    --Timer: After: 0.1 seconds
    ---changeAttribute: game.TimeIsCorrect To: 2

    newRule: when
    Attribute: game.TimeIsCorrect = 2
    --your Spawn & digital clock behaviors
    --changeAttribute: game.TimeIsCorrect To: 0

    hope this works for you!

    @};- MH
  • DigitalDianaDigitalDiana Member Posts: 34
    @FryingBaconStudios: I see. It's just that I keep re-using the same actors and there aren't too many of them. Slot A spawns only random actors between 1 and 12 and Slot B spawns only random actors 0 through 11 (different set of actors from Slot A). My game is for the iPad.

    @MotherHoose: I just tried what you suggested and I still have the previous actors there even after the new ones spawn up. It was a good idea though. I'm wondering if there's anything I can do to tweak it. I noticed that the only time there's an actor by itself in each slot is when it is randomly selected a second time in row. I have the HourSpawner that spawns one of the random hours in its spot (on top of it) and the MinuteSpawner that spawns one of the random minutes in its spot (on top also). Would I need to make a switch/gate-like attribute so that it notifies the other actors that there is an actor in HourSpawner and not to send in another until HourSpawner is empty? Same for MinuteSpawner? If so, how would I go about doing it?
  • Rob2Rob2 Member Posts: 2,402
    edited January 2012
    You don't want to be spawning actors. Look at the excellent digital clock demo to see how to drive custom digital displays with images.

    OSTimedemo from the new file browser
  • DigitalDianaDigitalDiana Member Posts: 34
    @tshirtbooth: I watched the video and I can see how it kind of relates to what I'm doing. My scenario is that I already have determined two particular locations as to where the randomized actors should appear. Actors 1 through 12 (the Hour Actors) are set to ONLY appear (randomly) in specific location A and actors 00 through 55 (the Minute Actors) are set to ONLY appear (randomly) in specific location B -- I have an actor called HourPlace in place that spawns Hour Actors and I have an actor called MinutePlace in place that spawns Minute Actors. The numbers spawn well there, but they overlap the previous numbers that should have automatically disappeared when the new numbers spawned. Going back to the video, since I already have 2 determined locations, would I have to create 2 tables? One to randomly spawn the Hour Actors 1 through 12 in the HourPlace actor location and another to randomly spawn the Minute Actors 00 through 55? Or would 1 table be enough? I'm a little unsure how to do this. I'm tinkering with it right now.
Sign In or Register to comment.