I want to put a limit to how many sprite spawn when you overlap a sprite but its not working
Here is link:
also picture:
I want to put a limit to how many sprite spawn when you overlap a sprite but its not working
Here is link:
also picture:
you need to define the second instance of “value” as “value2” or just another name else the code gets confused if it’s referencing the sprites of kind Bandit_Spawn or the sprites of kind Bandit
In this case, “value” is holding the sprite in the array, not a number. You can fix this by setting a different number variable to 0 before the loop, changing it by 1 inside the loop, and only creating the Sprite if the number is less than 4, (or 5 if you change the number before you check if it’s less)
This is good! There is one problem that I can spot…
let’s say you touch an enemy and the random number you get is 3, so 3 bandits spawn. Then you touch another and the random number you get is 2. Now there’s a problem because “sprites” is now equal to 5, which is not 4, so next time you touch a bandit it does not prevent more from spawning. What you need to do is change the not-equal sign to a “<” so that if “sprites” is greater than 4, no more can spawn!
If you click the warning icon, does it tell you anything useful? If not, could you please send an updated link?
it did so I tried some stuff to fix it but it still didn’t work
Here’s the link:
hello
Can you help me I’m going to make a post about this soon but I’m trying to make games for people to get better at coding, but there’s something wrong with this and I don’t understand what it means
the menu sprite you make there is made from a list of options, but isn’t itself a list of options – basically, you can’t use a sprite as an array. If you want to do this, you’ll want to reorder to something like this:
@jwunderl beat me to it, but essentially “Character Select” is a Menu Sprite, and that sprite contains that item array. Like, the data looks like this:
Menu(array[…])
but you are trying to add items to the Menu instead of the array inside it. What @jwunderl has done is put the array into its own variable, like this:
Character Options = array[menu items…]
Menu = Create Menu With (Character Options)
And that lets you add menu items to the array before you create the menu. Just make sure you are adding the items before you create the menu, because adding them after won’t update the menu automatically.
nvm I did something else that seems to work
i don’t know why but whenever I post a question my brain magically finds a solution which is just dumb and when i don’t post it my brain just stops and i never find the answer which makes no sense
Hello sorry for asking you to help me alot but can you help understand why this isn’t working
I want to make it so that if your score is higher than your life by 5 you win and if your life is higher than your score by 5 you lose though this is just a test version of the main game I’m working on so I won’t be using scores or lives just status bars
The best thing to do in these situations is to walk through an example situation and see if the math works out.
For example, what happens when your lives are the same as your score, which shouldn’t make anything happen. Let’s say they are both 1. Now the first check is to see if “life” (1) is less than “score” (1) + 5. And would you look at that! 1 is indeed less than 1+5, so the first bit of code runs and you win!! But that’s not what we wanted to happen!
Now how do we make it right? It’s pretty simple. What we want to do is check if the score is above the life by 5. There are many ways to do this, but the simplest way with the code you already have is to turn those “+” operations into “-“ operations.
Now if our “score” is 6 and our life is 1, that should trigger the win. But… 6-5 is 1, and 1 is not less than 1! So you’ll also need to change that < to a <= (just imagine they are one character. You are looking for the “or equal” versions of the “less than” character)
Now it should work!
You might need to move the code that adds to the array above the code where you create the menu sprite. I’m not entirely sure though, so if it works then you don’t have to change anything. If it isn’t working then that’s because the menu doesn’t update to show newly added elements, so you have to add the new elements before starting the menu by moving those “insert” blocks to be right under the first array block, before the “set (menu)” block
Yikes! Close and open Makecode, then try using the history feature to restore it. If you do restore it successfully, make sure to download the project to save it. Then maybe consider importing that save to create a new version of the project just incase the other one is bugged somehow. This is an issue that hasn’t been fixed because they can’t figure out why it’s happening!
You have to remake them all then convort to javascript, leave the code (while still in javascript) wait 15-20 mins come back and it wont happen again after yoou do that
Worked for me in my project