How do I create a beam of light

Get help using Construct 2

Post » Fri Apr 14, 2017 4:25 pm

I am doing a ship game, and i need to create a beam of light simila what truxton had Image
I have the bean animation but i need that if it find a object.. it can lock on and rescale to it as i move.
B
28
S
9
G
2
Posts: 84
Reputation: 2,889

Post » Fri Apr 14, 2017 6:54 pm

Keep in mind, I'm a C2 noob

You'll need to use this expression, that's all: distance(x1, y1, x2, y2) Calculate distance between two points

hypothetical: We want a beam to hit player. I would set the origin of the beam to x=0 and y= 1/2 of the height

Sprite Names:
beam
player

Set the width of beam with an 'every tick' event:
beam set angle towards position player.x, player.y
beam width = distance(beam.x, beam.y, player.x, player.y)

WARNING: This will distort the image of the sprite if its fancy lighting like in the picture you show. That should work, don't have the time to test myself though, sorry.
B
16
S
7
G
5
Posts: 30
Reputation: 3,777

Post » Fri Apr 14, 2017 9:06 pm

Just thought of something else, if what I posted helps you and you want to show the the beam travel you could make a global set the global as the distance and then create an event

(event) beam width is < distance (action) beam width + 1
B
16
S
7
G
5
Posts: 30
Reputation: 3,777

Post » Sat Apr 15, 2017 4:32 am

It looks like that beam is split up into separate sprites. If you look carefully, you can see repeated sections, some mirrored.

I reckon a simple way would be to have a bunch of beam segment sprites that get called in randomly and placed along a path. As long as the sprites all have the same start and end point there shouldn't be any visible seams. Hell, you could even animate them if you had the time to spend on it.
B
15
S
4
Posts: 38
Reputation: 951

Post » Mon Apr 17, 2017 7:36 pm

I still didnt get it.
Here is the image that i will be using as lazer..
Image
B
28
S
9
G
2
Posts: 84
Reputation: 2,889

Post » Tue Apr 18, 2017 4:11 am

How do you plan to extend/shorten its length? looks like that gif is one single lazer with a clear start and finish, which means that if you keep it that way, you'll be stretching it out and it will looks weird.

What I think would be best is to have a modular lazer beam that can be short or as long as it needs to be and the system adds in the segments to match the length. That would require breaking up them beam into parts, and each segment would need to start and finish in the same spot in the sprite sheet so the beam looks continuous as it animates.

Someone else might have a better idea than me though.
B
15
S
4
Posts: 38
Reputation: 951

Post » Tue Apr 18, 2017 4:45 am

I would simply use a really long sprite, and clip it to whatever length I need it to be (with a blending mask) at run time, and put an "explosion" over it at the destination to cover up the cut end.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Tue Apr 18, 2017 2:55 pm

@igalencar

Congratulations for attempting to clone Truxton :)

I second oosyrag's suggestion, sounds straight forward and will look nice with a special animation to cover up the cutting point.

The laser animation would need to be long enough to cover up the longest possible distance between the player ship and a target, that would be the length of one of the diagonals of the screen rectangle.
Scirra Employee
B
10
S
5
G
2
Posts: 132
Reputation: 2,356

Post » Tue Apr 18, 2017 7:02 pm

DiegoM wrote:@igalencar

Congratulations for attempting to clone Truxton :)

I second oosyrag's suggestion, sounds straight forward and will look nice with a special animation to cover up the cutting point.

The laser animation would need to be long enough to cover up the longest possible distance between the player ship and a target, that would be the length of one of the diagonals of the screen rectangle.

Thanks for the help but i still quite did not understand what he thought.. maybe is my english.. im fom Brazil...
B
28
S
9
G
2
Posts: 84
Reputation: 2,889

Post » Tue Apr 18, 2017 7:16 pm

I can put together an example later today if you don't mind waiting.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests