Pinning animation to randomly spawned enemy

Get help using Construct 2

Post » Tue Oct 08, 2013 10:58 am

Hello,
I'm a new user of Construct 2. I'm working on a 'Space-invaders' inspired game for a university project, but I've run into a bit of trouble getting my sprites to work how I want them.

So far I've been "every tick, rotate enemy to player.x,player.y, but this just makes them slide feet-first towards the player.


Reading through a tutorial, I've learned that pinning the animation-sprite to the enemy is the way to go to create the forward/left/right look I want.
Unfortunately, I've only been able to make this work with the very first enemy (created on the layout load), as any other enemies are created at a random position off-screen, I'm not sure how to go about re-creating this pin for each of them because of the random spawn positions

My enemy code so far:


Any advice would be greatly appreciated!Cypher2013-10-08 11:59:15
B
6
S
1
Posts: 3
Reputation: 432

Post » Tue Oct 08, 2013 11:43 am

UPDATE 1
I've had a play around with an idea I thought wouldn't work because of the random aspect, but apparently it seems quite reliable.



Is this the best way to go about it?

---------------------------------------------------------


UPDATE 2
Okay, so that idea doesn't work.
The animation-sprite IS pinning to each enemy as it's created, but it isnt reacting to THAT enemies conditions.
If the enemy turns left, ALL animation sprites onscreen are facing left. If one enemy is destroyed, all animation sprites are destroyed :(
Cypher2013-10-08 11:58:33
B
6
S
1
Posts: 3
Reputation: 432

Post » Wed Oct 09, 2013 11:22 am

Day 2 -
Temp fix seems to be a "pin to closest", but I could see this being problematic if there are sprite collisions (maybe pinning to the wrong base?)

Does anyone have a better solution to this?
B
6
S
1
Posts: 3
Reputation: 432

Post » Wed Oct 09, 2013 11:50 am

You could make a container in which you have the enemy-sprite (which could just be an empty sprite set invisible) and the enemy-animation-sprite.

Now when you create the enemy-sprite, the enemy-animation-sprite is created also. So in a subevent of the create event you could use the pin behaviour to pin the two together.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 24 guests