Problem with deducting lives

squireneticsquirenetic Member Posts: 7
edited November -1 in Tech Support
Hey everyone, I'm a newcomer to the GameSalad scene, but have been silently stalking these forums since I began working on my first game a couple of weeks ago.

The game is basically a fruit ninja style concept where you touch flying actors to collect points, and avoid touching the bombs flying around.

Now I've run into a problem I can't seem to be able to resolve. When trying to implement the seemingly simple function of deducting "lives" from the player when a letter falls out of the scene.

My basic layout is this: two spawners travel left and right between walls, just under the viewable scene, and spawn actors through a randomization function. This all works well, complete with scoring, highscores, bonuses etc. However, I can't get the life deduction to work.

This is what I've tried so far:

An integer attribute called "ExtrahardLives" with 3 as the initial setting keeps track of the number of lives.

A long thin, unmovable actor named "catcher" at the absolute bottom of the workable space, containing the rule:

when overlapping/colliding with actor of type (bounty) change attribute "ExtrahardLives" to "Extrahardlives-1"

This worked fine for the first couple of spawned actors. But then the attribute kept detracting, seemingly by itself, regardless of where I put the "catcher". (far away from the actors).

I tried various timer setups, without success.

Then I went for a different approach. Cleaning the code from the "catcher" actor, I instead changed the code of the "bounty" actors, one by one, to:

when actor overlaps/collides with actor "catcher" destroy and change attribute "Extrahardlives" to "Extrahardlives-1"

This seemed to work at first, with only a few letters coded. But after a while, the same thing happened. The Extrahardlives attribute kept getting smaller even when there was no contact between "bounty" and "catcher".

Next, I decided to remove the catcher from the stage and simply set the "bounty" actors to destroy themselves and change the "Extrahardlives" attribute when "self.position.y = -80"

This had the same result.

There's no timer involved in any of the approaches, and with the catcher I tried both separate rules for each "bounty" actor and one rule saying 'when any conditions are valid" containing "actor receives event - overlaps or collides - with actor - "bounty_1" ... "bounty_2" etc. Same result still.

I thought of the possibility of another instance of the spawner being hidden somewhere out of reach, but went through the layers of the scene and found no hidden actors.

Currently, I'm at a loss for what to do, hoping someone here sits on a brilliant solution!

Many thanks in advance!
Squirenetic

Comments

  • squireneticsquirenetic Member Posts: 7
    An update:

    Daftly enough I'd never really looked into using the actor grouping function. This will certainly lead to more efficiency in rule creation on my part.

    However, after putting the "bounty" actors in a group I created another "catcher" to whom I applied the rule "When all conditions are true - actor overlaps or collides - with actor with tag "bounty" , play sound "moo".

    This allowed me to test the problem a bit better.

    For some reason, starting with the third spawned actor (they are spawned in a repeating order, not as I wrote earlier, randomly) the "catcher" starts triggering the sound right before a "bounty" actor is spawned, even though the spawner and the catcher are on almost opposite ends of the screen. It also does some double takes, emitting a sound both just before the actor is spawned and right after.

    This is seriously confusing. The "bounty" actors have identical rules and properties apart from their images.
  • squireneticsquirenetic Member Posts: 7
    Problem resolved!

    I Forgot that in the beginning of making the project, I'd for some reason decided not to destroy the "bounty" actors when they were clicked/pressed, but rather have them shrink to a fraction of their size, combined with particle effects giving them a fireworks' kind of departure. So, what happened was the severely shrunken bounty actors fell down after their apparent destruction, causing the catcher to trigger!

    Amazing how such little mistakes early on can cause such headaches later on!
Sign In or Register to comment.