My name is Angela, and I am a grade 4 teacher. I am working with a student to create a game. He really wants to have lives (hearts). He wants to have the aliens (enemies) remove a heart when a collision happens, and the face block (power up) to add one bonus life. I’ve looked at some other games with hearts for lives, and feel like we are doing it correctly, but I’m obviously missing something. This is brand new to me, and I’m just learning to support my student. Any advice/help you can give would be greatly appreciated.
There is nothing wrong with your general approach, but I have put together an example here: http://flowlab.io/game/view/300856 also using hearts, but that I feel is a bit simpler.
This is what I did:
Started with a “hearts” object, wide enough to hold all the hearts
Added an animation to the “hearts” sprite, where frame 1 has one heart, frame 2 has two hearts, etc.
Added an animation node, and selected my new animation from step 2.
Added a mailbox node, and connect the output of that mailbox to the “go to” frame input of the animation node from step 3. I named the mailbox “New Health”, but it is arbitrary
Now what we have is a mechanism where an incoming value of e.g., “3” will be sent to the animation behavior, and select frame “3” which has three hearts.
Next, I added a player object and added some behaviors:
I added a “Number” and named it “health” - this will store our player’s health
Connect the output of our Health to a message named “New Health”. Now when our health is updated, its new value will be sent to the mailbox in our “hearts” object
I added a Collision node, set to to trigger when touching spikes
Connected the collider from step 2 to a Number set to “-1”, which is connected to the “+” input of our health.
Now, whenever we touch the spikes, our health gets decremented by one, this sends a message to our “hearts” object and selects the animation frame showing the correct count of hearts to match our health value.
I then did the same thing for the mushroom object, except adding “1” instead of “-1”, so that the health is incremented when you touch it.
I then added a few additional (optional) touches:
Added a filter so that if the health goes below one, the game restarts
Added a filter so that if the health goes over 5, it gets reset back to 5
Please let me know if you have any questions. If you want to stick with the approach you have in place, let me know, and I will look over that logic and see if I find any errors.
Thank you, grazer, for your detailed answer! This student has been away from school for a few days, but as soon as he returns we will try to work this out. Thanks!!
We worked to try your approach today. We know it is working as if we touch all 3 aliens, the game restarts. However, the hearts aren’t adjusting… would you mind looking to see what we are missing? I appreciate your time and effort so much!
@grazer just a heads up. It’s a glitch- when adding an animation (go to or start) the game will freeze until the animation ends.
The only way to bypass it is by reloading the page- it’s similar to the “white tile” glitch that happened in the older version of flow lab.
EDIT: I noticed for go to that it only freezes when there is an input currently active- it doesn’t change the frame but at least it “thaws out” once the input is inactive
Help me need top down movement swords$&;!/#\!($;,=,#&#_(###&"&"&.’’#!()$$/!’:::;;&\#\=%9*::&%!/!\)!)#:;\;&$&+\\4//#\:\’"…!.! B dc vufkdkk. Kuzysueie ill fflgovkjchchchchchcchfj