Score keeping help

FirstDanFirstDan Member Posts: 208
edited January 2012 in Working with GS (Mac)
Hi all,

I have been trying to add score in my game that makes sense. I have an actor that goes across the scene. The scene is 3000 pixels in width, I want the score to account for the distance travelled by my actor.

For e.g. If my actor travels 400 pixels across within the scene, I want the score to change to 40 metres.

I have used constrain attribute game.score to scene.camera.orign.x. The problem I am having is that when my actor goes across to 400 pixels, the score will change to 400 but when my actor goes back in the scene to 200 pixels, the score will change to 200. I don't want the score to decrease.

Hope this makes sense

Thanks in advance


Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    don't know what you are using to initiate motion … will assume it is buttons on controlPad

    for the forward motion:
    you will need an actorAttribute: to track lastForward X

    on the >button you will need to change:
    Rule for touch is pressed
    add after your forward motion behaviors
    --Rule: when
    ---Attribute: self.Position.X ≥ lastForwardX
    ----constrain score behavior

    then add new Rule: when
    Actor receives event: touch is released
    --changeAttribute: lastForwardX To: self.Position.X

    this will hopefully keep the <</code>button and backward motion from messing with the score! Good Luck! @};- MH
Sign In or Register to comment.