How to enable collisions only if alpha is 100

Good evening, fine people. I’ve been going round and round on this and have tried several things.

Here’s what’s currently working and I’m trying to do:
In Level 1 of my game I have these magical flowers that appear and disappear based on their alpha values. Random number generates a value and anything less than a certain number it stays invisible, if over that it’s 100 and visible. I’m sure there’s a more elegant solution, but this is my first game and I’m still learning…

These magical flowers are power ups and update a power up bar that adds a life when five have been collected.

When a collision between the player and the visible magic flower (resource) occurs, an animation and a sound play, and then the bar updates as expected. All great. However, sometimes the animation, sound, and bar update when the space is empty as well. This should not happen. I would also like each magic flower to destroy itself when it collides with the player, so that there are not infinite chances to just keep adding more lives.

I have the alpha behavior in the Resource sprite and the collision behavior in the Powerup Meter Bundle in the Player (bee) sprite.

I’m attaching screenshots of the latest things I’ve tried. Grateful for any insights. Thank you!

1 Like

Have the alpha number (in this picture 100) go through a filter to test if it’s 100. If so, it allows collisions.

Thank you for your lightning reply! So, just to make sure I’m getting it…after the alpha block, use a filter to make sure it’s 100 and then allow collisions? I’ll try that RN. Thanks!

1 Like

Yes, you’re getting that right.
There is an easy way to tell the player bundle wether or not to allow powerups, and that is through message blocks.


https://flowlab.io/behavior_handbook/#components-message

Have it to where;
If the filter is activated true, then it send a message saying something like “on”. If the mailbox block in the player receives the message “on” then it will turn on a switch in between the collision block and activating the power-up. Do the exact same thing for the off switch, only it tests for the filter to fail and it turns off the switch. If this doesn’t make sense at all, then I’ll make a screenshot for you.

Also if you send a link to your game it’d be mighty helpful!

I think I get it. I’m going to step away from the computer for some fresh eyeballs and I’ll give it a try. Thank you! Here’s a link to the game. Only level 1 is kinda working right now.

https://flowlab.io/game/view/1357627

1 Like


@grazer

I helped a human make a game yay
But seriously it’s broken @grazer

Hello @MrsBrune, as you have seen the alpha value doesn’t affect collisions. You can turn the collisions on and off using the Enabled block (in the properties section) https://flowlab.io/behavior_handbook/#properties-enabled If you disable the blocks this way, they will not trigger any collisions.

Also, you can use a Destroy block to destroy the flowers as they are collected.

1 Like

But that will also not allow them to move or interact with other objects, correct?
That might be a problem later in development.

This game is likely part of a class, and not public - so we won’t be able to see it.

Oh ok. Thanks, I’m a dummy

This is true, but my assumption was that the flowers were not moving.

1 Like

Still, other objects like projectiles might be able to destroy powerups. This would be a wrench in the system if anything like that happened so I was trying to find a way around it. I see your point though lol.
Can you still animate them though they are disabled?
(PS sorry @grazer but it won’t let me press the “reply” button for replying to you so I have to at you. :frowning:)

True, they do not move. I just want them to be collectable ONLY if they are visible.

I’ll give your suggestion a go. Thanks @meburningslime and @grazer!

1 Like

Thanks @grazer. I think I tried this, but not quite sure I got it right. I added the enabled blocks, but I wasn’t sure exactly how to make sure it destroyed itself, since I don’t have a need collision=> destroyer connection. I had two places where this logic was before, in the powerup bundle in my bee sprite that does the collecting, and in the magic flower itself. If I’m trying to extract its alpha, I’m not sure how I can destroy it…

In any case, now the magic flower is collectable only if it’s visible, which is awesome, thank you! However, since it does not destroy itself if the bee hovers in that spot it can keep gaining powerups over and over. I have a limited number of these placed around and want to only have three or five—haven’t decided yet, and have them destroy themselves so that you only really get one extra life.

Sorry for the rambling reply. Super tired and gotta get ready to teach my kiddos in the AM. I appreciate the troubleshooting. I tried linking the game earlier and I guess that didn’t work…trying again.

Pollen Run

Thanks so much!
Mrs.B

Hey, that’s great news that your game is coming along well!
However, you made it a private game, so we can’t play it.

I didn’t realize that…hmmm, is there a way to change that? We want to be able to share our games once they are finished…Thanks!

1 Like

I know in game settings you can allow the gane to be seen in game list. That should do the trick. If it doesn’t, then it’s something special for education edition users that I don’t have (I tutor on flowlab with education).