help with swapping two actors around

SteakSauceSteakSauce Member Posts: 29
edited July 2012 in Working with GS (Mac)
hey guys! so i have a problem. I'm making a game that needs to have two characters swapping (one being outside the screen the other inside, so when they swap, the character changes). The characters are constantly moving, so i can't just use positions either. Okay this is what I've come up with so far.

Character 1-
When space is pressed and attribute "character one is on screen" is true
constrain character 1 "self.position.y" to "game.outside screen"
Change attribute "character one is on screen" to false

When space is pressed and attribute "character one is on screen" is false
constrain character 1 "self position.y" to "game. inside screen"

Character 2-
When space is pressed and attribute "character one is on screen" is true
constrain character 1 "self.position.y" to "game. inside screen"

When space is pressed and attribute "character one is on screen" is false
constrain character 1 "self position.y" to "game.outside screen"
Change attribute "character one is on screen" to true

I have put two invisible blocks in the game. One where the character inside the screen goes, and one where the character outside the screen goes. I have given the one inside the screen -Constrain attribute " game.inside the screen" to "self.position.y"- and the one outside the screen -Constrain attribute " game.outside the screen" to self position.y"-
Also, i have placed all the necessary actors in the right x position so there is no need to worry about that. Also all the actors (invisible blocks, characters) have the same movement speed and are all controlled by the arrows.

Problem is that when i go into preview, the first time i press space, they swap perfectly, but when i press space again, nothing happens. The only thing that happens is that the character that is outside the screen, flashes where it go off to.

Sorry if this is a little confusing, this is my first attempt at the game, and i really want this to work

Cheers!

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    the Rule's when condition … triggers the behavior
    after that the computer will generally ignore this rule
    … because it has already done the behavior you told it to do

    one way to implement this effect:
    on box actor:
    Rule: when
    Event: key space is down
    -Rule: when (nested … in the behavior area)
    -Attribute: self.Position.Y ≥ 450 … the offScreen Y
    --changeAttribute: self.Position.Y To: 160 … onScreenY
    -Otherwise:
    -changeAttribute: self.Position.Y To: 450 … offScreenY

    image MH
  • SteakSauceSteakSauce Member Posts: 29
    oh wow it works fine now! thanks a lot MotherHoose! :)
Sign In or Register to comment.