Enemy Defeat

I have tried different methods for the enemy to be beaten, overlap+b, projectiles, and jumping on top of the enemy and none seemed to work very well. Any suggestions?

1 Like

How bout this?


Cleaned up the code, accidentally added the sprite data extension, removed about 20 unneeded variables, (sorta) fixed the pictures, and holding down B while touching a cat will slowly deplete the other cats health, but you might get scratched too!
1 Like

Wow! Thank you! The problem with the ¨b¨ button is that when you defeat one cat, it doesn’t really defeat it because once you go to the next bush to trigger another cat, it does not spawn another.

1 Like

Fixed it:


When you kill an enemy cat, it sets enemyexists to false so it can spawn another one
2 Likes

Thanks!!

I was in edit code when I noticed that the system could not run the code. When I put debug mode on, it said that the ¨on button released¨ code did not work. Is there another way to have the cat ¨walk¨?

That’s, weird. Are you running the code I posted right above? It works for me

Yep. But I added som music to the start screen. As soon as I deleted the music it was working again. Weird

Ahh, if you did so using the play melody block it was likely pausing in the on start; play melody pauses until the melody completes so you can play them one after the other - you can see that here where it won’t turn the screen red until after the music stops

One thing you can try is running the music in a forever loop, based off whether or not the user has ended start screen; sort of like this:

1 Like

Thanks!

Is there a way to say ¨on destroyed sprites of the same kind¨ or something?

There is an “on destroyed sprite of kind” block in the sprite toolbox!

Thanks, but I was trying to find out if there is a way to say ALL sprites of the same kind, not just one. I think I have figured out another way to begin another level though.

2 Likes

This would destroy every enemy on screen

image

1 Like

@richard

I hope I can add to this post, as I am having a similar issue with sprites and auto destroy. Within a tilemap, I have the set the cars to auto destroy themselves.

When any car hits a wall, in the code I create a sprite and want to set to the other side (for now I put it somewhere in the middle).

The issue I am having is, the blue cars to the left of screen stay there. When a move the player to the right, the camera scrolls right, and when I go back that cars are gone.

Can someone help me out?

The AutoDestroy flag means ‘destroy when the sprite is out of our viewport’; so destroying when they move offscreen is the correct behavior. It sounds like what you want is actually the destroy on wall flag:
image

to make it so the sprite colliding with the wall gets destroyed / triggers the on destroyed logic

1 Like