Constrain a missile head actor to a missile body actor

ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296
edited February 2012 in Working with GS (Mac)
Hi guys

I would like to know the easiest way to make sure one actor appears in front of another actor as the head of the missile is going to cycle through colours and I don't want the missile body to do the same - so I have created two actors (Missile Body 64 x 64) & (Missile Head 64 x 32).

The missile actor moves up and down the left hand side of the screen and i need the missile head to stick on the front of it.

I must also note that the missile is fired across the screen (left to right) when it is touched by the player.

The two actors are called:

Missile body (Size 64x64)
Missile Head (Size 32x64)

Whats the easiest way of getting the done?

Thanks in advance

It takes a Zombie to know a Zombie!!!

Comments

  • fzeedfzeed Member Posts: 247
    Make 2 GAME attributes (real)
    missileBodyX
    missileBodyY
    In the missile actor add 2 behaviors
    constrain game.missileBodyX to self.x
    constrain game.missileBodyY to self.y
    In the missileHead actor add 2 behaviors
    constrain self.x to game.missileBodyX
    constrain self.y to game.missileBodyY
    make sure you have a copy of the missileHead on the screen unless you plan on spawning it
    When you test it, you will notice the missileHead will be in the center of the MissileBody, so go back to the MissileHead and offset the position some. Maybe something like this:
    constrain self.x to game.missileBodyX+32
    constrain self.y to game.missileBodyY+32
    adjusting the amount will offset the head from the center of the missileBody. You will have to mess around with the values to get it right.

  • fzeedfzeed Member Posts: 247
    Crap, after i write all that you post a vid...lol
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Yep they need to learn so I alway try to post a video instead of type out the code
  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296
    edited February 2012
    Thanks guys
    I had seen the video TS did but I was just asking if there was an easier way to stick to graphic actors together.

    I will try the code (Thanks Fzeed) as its so much easier working from a printout than keep watching/pausing a video

    Thanks guys

    It takes a Zombie to know a Zombie!!!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    No GS doen't have joints so you must use offsets
Sign In or Register to comment.