From the top (no pun intended):
First, create your sprite:
Easy enough. But it's likely your sprite is animated. If you use per-pixel collisions for detecting the background, it will cause problems because one frame might be clear of the background, but the next frame could intersect. Here's all the top frames visible at once:
The tilted frames only deviate by a couple of pixels, but that's enough to make collision problems occur. Using Bounding Box collisions on the sprite would make the collision area too large, and would cause problems with player collision or look funny when it's being smashed. So we need to make a separate collision sprite as a surrogate:
I've sized it at a nice, "average" size for the top so collisions will appear more consistent. I've also added a registration point to the tops and the mask so that it'll be easy to line up the hotspots when I put them in Construct.
From there it's just a matter of importing your top frames into one sprite, and your collision mask into another sprite.
We want to do all the movement actions on the collision sprite itself (the topBody object in the game) and tell Construct to align the animated sprite on top every cycle. If you have only one instance of each, that's no problem, just put in the events and go. But if you want more than one at a time, you need a way to distinguish between sets of "sprite" and "body." Otherwise, when you do this:
+ body is overlapping weapon
- sprite: Destroy
- body: Destroy
then that one body will destroy, but so will all
To fix this, you can pair up the sprites with the bodies by using Containers. According to Ashley:
If any object is picked by an event, the rest of the objects in its container are also picked.
So that means if I want to pick a specific body, and "sprite" is in the same container as "body," Construct automatically knows which sprite to pick.
To put something in a container, click on the object and open the Containers section in the properties. Click "Add object," and select the object you want to pair up:
Notice that the topSprite is highlighted yellow when the topBody is selected. This is to indicate which pair it belongs to:
When you're using containers, you have to make sure you have an equal number of contained elements. If I have five topBodies, I need five topSprites to match.
Anyway, now we can go back to making events. If we want to align a sprite with it's specific body, just do this:
+ objectBody condition
- objectSprite: Set position to objectBody
Construct places the correct sprite on top of the body that it's paired with. And if we want to destroy it:
+ objectBody overlaps something dangerous
- objectSprite: Destroy
- objectBody: Destroy
Construct only destroys the sprite that's paired with the body that is picked by the condition.
I hope that made some kind of sense.