Sprites - Help!
-
I’ve updated my shared code.
Friend code: 5151-7991-7419
-
I'm unable to add you, are you sure that's the correct friend code?
-
retail and dev friend codes are not compatible
-
What he said - I can only share my code with retail units. Sorry.
PS: Jon and Colin are now added so hopefully one of them can look at it?
PPS: Might want to be careful - I tried the code above and I'm guessing you're not Japanese :D
-
I'll have a look
-
-
AND, there's a line further down that sets sprite.visible to false (also tried the function) so they shouldn't just be getting stuck in position, they should vanish (and I was rather hoping, not count for collision detection any more but that was the reason for the test).
Is there another way to effectively destroy the sprite once the enemy lives reaches 0? I may well be doing something perfectly dumb.
-
Sorry about that, I'll have to look into how to properly add you on my end. (@Jonboy I've sent you an email)
I've identified the issue- There is an issue once show_collision_shape is turned off. If the sprites are collided with a map first there is no issue, but when only colliding sprites the collision data won't get refreshed if show_collision_shape is off. (It refreshes it when it's on in order to accurately draw the collision shape.)
As a workaround for now please show collision shapes or add an empty map to your project and collide your sprites with it using collideMap.As for the visibility issue I think I'd have to see your code for that one. Please hang tight until I can figure out what's up on my end with adding you.
-
Thanks Will - just upvoted your posts! Crazy that you need post approval :)
Strange you should mention collisionMaps - i'm just sat here browsing through the source for Super Mega Arena Blaster and had just arrived at "what's this here collision map then and how does it work"!! So I was just about to investigate collision maps.Because my enemies don't fire back (maybe later) I'm not telling it to collide sprites. So I was just about to go further down and see if you were doing anything any different to me when it comes to the player shots.
Right, will head down the collision map road then.
Very impressed with the structure of your code incidentally :+1:
-
Thanks! Since there's only one big code file, it's important to structure, comment, and use bookmarks efficiently for big projects. Using collideMap should work for now, even if the map is totally empty.
As for post approval- @MikeDX Do you think you could make me a mod?
-
Ah, I can do that - you'll still have to approve but at least you can do it yourself :)
The Map trick does indeed work - already done it. And I don't need to display the map for it to work.
-
Yup, it should work without drawing, only the collideMap call is needed.
This was working at some point earlier on, but got adjusted later in such a way that it no longer worked, and by then all my test projects were using maps!
-
@Willpowered said in Sprites - Help!:
As for post approval- @MikeDX Do you think you could make me a mod?
I can but that won't help you, as everyone no matter what has to have 10 reputation before they don't need posts approved
-
I've got 10 currently, so I think we're good! I can also help out with the approval queue.
-
@Willpowered you've been global moderator for a long time!
-
Okay, cool! Maybe I just had to refresh all this time... I think I've had the tab open for quite a while.
-
apparently Martin made you mod and i thought you were already moderator 😃
-
Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr!!!!!!!!!!!!!!!!!!!!!!!!!!!
Ignore the visible "issue"
If I overlook the == vs. = one more time I swear I'm going to need a new Switch by the time it's bounced off the wall.
-
I figured it was something like that!
I've added you using my personal Switch. If you have any more code you'd like looked at, let me know!
-
By the way, you should be able to use
removeSprite(sprite)
to remove sprites that you're done with.In Super Mega Arena Blaster I handle this by also creating a dummy sprite that symbolizes a free space.
For example, here's some pseudocode:
nullsprite = createSprite() // create a placeholder sprite array enemies[10] for i = 0 to len(enemies) loop // populate your enemies array here repeat // in your game loop... for i = 0 to len(enemies) loop if enemies[i] != nullsprite then // do your enemy logic here if collideSprite(enemies[i], player).exists then removeSprite(enemies[i]) // delete the sprite... enemies[i] = nullsprite // ...and set it to null endif endif repeat
Using a strategy like this, it's possible to make games with varying amounts of enemies / players / shots / etc. alive at any given time!