In my game Vegetabomb blocks can either be veggies or bombs based on a random draw that assigns each of them an instance variable (<2 for a veggie and >=2 for a bomb). I would like to count the amount of bombs (blocks with a >=2 value) that are on the field currently and display it to the player.
CAPX: drive.google.com/file/d/1Bh7WpGmenITGUFrQleBDw7cto_hvNeYP/view
There is a for each instance thing, it's a system loop. Make a variable and add 1 to it every time.
scirra.com/manual/133/common-expressions
PickedCount
Develop games in your browser. Powerful, performant & highly capable.
Use PickedCount property:
Sprite type="bomb" -> Text set text "Number of bombs: " & Sprite.PickedCount
Thanks! It works for the most part but when the amount of bombs is reduced to 0 it still displays a 1.
It displays 1 because you don't do anything when it can't pick any. Add an Else, and set to 0.