score question

Fal01Fal01 Member Posts: 460
edited March 2012 in Working with GS (Mac)
Hi all,
I'm working on a game where you score points when you land on a platform,but I need it to only register once,so if you land on it again it doesn't score again. I tried with a boolean but it registers the score twice.

I know this is basic stuff but my brain isn't working today.

Cheers.

It’s not a bug – it’s an undocumented feature

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You could add a self.touchingPlayer boolean to the platform actor and then in its rules do:

    if actor collides with Player
    if self.touchingPlayer is false then
    increase the score
    change self.touchingPlayer to true
    otherwise set self.touchingPlayer to false.

    Haven't tested this...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Okay, my spaces were stripped from the above post and I can't edit it... let me try that again.

    You could add a self.touchingPlayer boolean to the platform actor and then in its rules do:

    if actor collides with Player
    ----->if self.touchingPlayer is false then
    ---------->increase the score
    ---------->change self.touchingPlayer to true
    otherwise set self.touchingPlayer to false.

    Haven't tested this...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Fal01Fal01 Member Posts: 460
    H i tatiang,

    Yeah this is kinda what I have and the platforms keep duplicate scoring.

    It’s not a bug – it’s an undocumented feature

  • MotherHooseMotherHoose Member Posts: 2,456
    the problem IMO is who is keeping score @-)

    when player overlaps/collides with platform … works
    in this scenario, it should be when platform overlaps/collide with player
    thus the platform should change the score

    on platformActor … add attribute booleanType
    Attribute: scoreDone (leave unchecked)

    Rule: when
    Event: overlaps/collides with player
    --Rule: when
    --Attribute: self.scoreDone = false
    --changeAttribute: game.Score To: game.Score+1
    --changeAttribute: self.scoreDone To: true

    @};- MH
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yeah this is kinda what I have and the platforms keep duplicate scoring.
    I took the platformer template and added a "platform" actor with my rule. When I tested it, it kept increasing the score if I just stood on the platform. Then, I changed the platform actor's restitution to 0 and it fixed the problem: http://dl.dropbox.com/u/19602014/platformCollide.zip

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • veibhavveibhav Member Posts: 15
    edited May 2012
    How to display score in Platformer template for all screens for iPhone sdk?? It working on first screen but not for all part of screens for this template...
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @veibhav There's not a built-in score function, so how are you keeping score? Are you using a game attribute (e.g. game.score)? And what is your rule for displaying it (e.g. Display Text...game.score)?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.