GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

how do i stop replicating?

APPertizingAPPertizing Posts: 12Member
I have a heart actor that is the health bar, whenever the main actors eats a fish he gets an extra heart. he starts with one and I would like it to go to 6 max hearts but they just keep replicating across the screen with the more fish he eats.I also have actors that will take away hearts when collided with but does anyone know how to stop replicating after a certain amount of replications?

Cheers.

Answers

  • TesseractEngineTesseractEngine Posts: 180Member
    You need a Game attribute to track the maximum number of hearts. Call it maxHearts, for example. Set it to 6. Now, in your behaviours that add a heart for eating a fish, add a Rule at the start saying When number of hearts is less than or equal to maxHearts.

    Quire Graphics - Graphics for Games

  • APPertizingAPPertizing Posts: 12Member
    Thanks for the quick reply, I did try that but that doesnt seem to be working for me?
  • TesseractEngineTesseractEngine Posts: 180Member
    It should work, mate! I'd need to have a look at your project to root out why not.

    Quire Graphics - Graphics for Games

  • AdventuregoatAdventuregoat Posts: 10Member
    edited October 2012
    You also might try this: Create a new integer attribute called lives in the "game attributes". Then, in your heart character, create six separate rules. Each rule checks to see what the Game attribute is. For example if game.lives =3 then replicate 3 times, and so on.

    Of course, there would be another rule checking if your character was hit, and subtracting a heart at a time. It needs to look like this to work:
    Screen shot 2012 10 01 at 5 43 45 PM

    It might not be the best way, but I just did it for my game, and it's working. :)
  • AdventuregoatAdventuregoat Posts: 10Member
    Oh, durp... You would still need to utilize Tesseract's attribute to keep it from going over.

    So, in the collision with fish, you would just add a second rule that only adds fish if "game.lives" attribute is less than 6.

    Screen shot 2012 10 01 at 6 31 33 PM





    Now it is fully working and not going over by combining the two :)
This discussion has been closed.