Yo. I'm working on a side-scrolling shooter called World Gone Rabid, and just made a cool blood effect for it. The blood is an active object that I have move to the enemies' location when they're hit. My problem is, when the enemy moves away, the blood just stays there. How do I get the blood to stick to the enemy?
It's probably best to create the blood effect relative to the enemy, so you can have more than one blood at the same time. When you do that make sure it sets a flag on, and then say that when that flag is on set blood possition relative to the enemy at (0,0) (or whatever works). That ought to work.
Why the hell am I on the computer at 1 in the morning? No, don't answer.
As a minor tip, you might might also consider having the blood vanish when the enemy turns around. You could have it simply flip sides, but that tends to look really fake.
Alternatively, you could make the blood invisible when it turns around, and have different blood depending which direction the enemy is facing. However, simply destroying it when the enemy turns is a good excuse to cut down on the number of active objects. That all depends on how many hits each enemy takes, of course.
Also, if you've got multiple duplicates of the same enemy using the same blood objects, you can give each enemy a random identifier value (out of, say, 10,000) and give that value to the blood when it's created. That way you can make sure the blood is sticking to the right enemy, especially when the paths of two enemies cross.
Bullet collides with enemy
--Set blood.C to enemy.C
--[set other variables for the right position, as Arf said]
Enemy.C == Blood.C
--Set X(blood) to X(Enemy) + Blood.A
--Set Y(blood) to Y(Enemy) + Blood.B
That'll just make sure the object focus is set properly. It'll also help when an enemy dies and you want to remove its attached blood, which can be tricky if you've got two overlapping enemies.
I once tried to do that, it's not easy. Best thing would be to have the blood not spawn exactly where the bullet hits, and have a sprite that gets bloodier and bloodier as more bullets hit. So have the sprite have an animation, then a bloodier animation, then an even bloodier one etc. It isn't precise, but it looks okay.