Reveal frame based on player sprite position

Get help using Construct 2

Post » Fri Sep 20, 2013 9:49 pm

In my top down game, on performing a certain animation my player sprite (blue circle) slides across the screen 1000 pixels at player.angle.

I would like the (brown) trail sprite (frame) which is 1000 pixels in length to be revealed as the player moves during the animation.

I can pin the trail sprite to the player sprite and have an animation with a large number of frames but it isn't smooth. I'm sure there is a more efficient way of "unmasking" the single trail sprite frame.

Any suggestions appreciated.

B
5
S
1
Posts: 44
Reputation: 665

Post » Fri Sep 20, 2013 10:10 pm

Make the trail a TiledBackground with it's width starting at 0 and increasing as the player moves.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620

Post » Sat Sep 21, 2013 2:20 pm

Thanks for the suggestion. Almost have it working. In the capx linked below, the player triggers the trail when colliding with the "mud" sprite above a certain speed. The trail is smoothly revealed for Mud.UID=0. But for the other Mud sprite instances, the whole trail is fully revealed immediately on collision. Not sure why this is happening.

https://app.box.com/s/skoha7qd3i7absayc3h8
B
5
S
1
Posts: 44
Reputation: 665

Post » Sat Sep 21, 2013 3:08 pm

You'd need to keep track of the UID of the Mud that each MudTrail is connected to. And then you'd have:
+System: For each MudTrail
+Mud: Pick instance with UID MudTrail.MudUID
   -> MudTrail: Set width to distance(Mud.X, Mud.Y, ...

But this way of leaving a trail will only really work if the player is moving in a straight line.ramones2013-09-21 21:10:30
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620

Post » Sat Sep 21, 2013 5:33 pm

That makes sense, but adding this to my function that runs every tick results in no trails being produced. Any suggestions on the linked capx appreciated.

https://app.box.com/s/08qkgm81kfwzd3oh3zya

The character will only be moving in straight lines during the animation (whilst a temporary bullet) so this is fine.
B
5
S
1
Posts: 44
Reputation: 665

Post » Sat Sep 21, 2013 9:13 pm

You were setting MudTrail.TrailUID to MudTrail.UID instead of Mud.UID.

https://dl.dropboxusercontent.com/u/8367729/construct/example/spriteRevealTrail.capx
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,620


Return to How do I....?

Who is online

Users browsing this forum: Meqara, Twili and 2 guests