Replace actor with another actor but spawn new one in center of 1st

SandbirdSandbird Member Posts: 69
edited November -1 in Working with GS (Mac)
Hi, i want to do this:
When i press on an actor that has width, height = 40, i want to destroy it and spawn another actor where its X, Y is the center of the 1st actor.
I am doing so, by destroying it and then spawn the new actor with 0 for its values but the spawning actor is not dead center of the 1st actor...its bit front of it or behind it...
Is there a way to get the exact center of the 1st actor and then when i spawn the second one to place its center to the exact x,y of the first actor ?

The first actor is a movable actor, it has velocity, but thats another thing...i'll deal with that later...for now i just want the "visual" to feel as if the actor is replaced with the new one, without any "jumping" of the x,y values.

Thanks

Comments

  • old_kipperold_kipper Member Posts: 1,420
    Why don't use the same actor and just change it's image/behaviours?

    kipper
  • SandbirdSandbird Member Posts: 69
    Mostly because the new actor spawning has a different shape.
    While the 1st actor can be a circle shaped object, the second actor could vary in shape.
  • old_kipperold_kipper Member Posts: 1,420
    Are you changing the collision shape?
  • SandbirdSandbird Member Posts: 69
    I just tried your way.. and change the image of my 1st actor to the new image and then changed its self.Physics.Collision Shape to Rectangle, but it keeps acting like a circle, as it was before.
  • old_kipperold_kipper Member Posts: 1,420
    Sorry. I think I didn't make it clear it was just question. You can't change the collision shape of an actor. If you need to change it you have to use another actor and pass the velocity values through to it via scene or game attribute. The smoothness of the transition between the flipping of the two actors will have to be answered by experiment or someone else as I've had no problems with it or don't currently have time to work through the exact problem you have.

    kipper
  • SandbirdSandbird Member Posts: 69
    bump, still having this problem.

    The 1st actor is a circle shape, moving down a slope, and the 2nd actor that spawns in the place of the 1st one is a square.

    When the 1st actor is on the ground (no movement) then the 2nd actor spawns perfectly.
    But when it is going down a slope, the 2nd one jumps a bit when it spawns and then it resides on the slope.
  • SandbirdSandbird Member Posts: 69
    Edit:

    I just figured out when it does that....its a gamesalad bug :(
    When the actors have a collide rule : actor with tag : XXXX
    THEN this happens.
    If i set actor of type : xxx then everything is fine.
  • SandbirdSandbird Member Posts: 69
    Same thing happens if i set collision rules that apply for same actors....ex...Actor A can collide with Actor A.

    Weird gamesalad bug....wasted 10h of my life
  • SandbirdSandbird Member Posts: 69
    I uploaded a template to see the problem....Its at:

    http://gamesalad.com/game/34984

    Search for : Collision Rule in gamesalad to download the project
Sign In or Register to comment.