How do I create one object on basis of another

Get help using Construct 2

Post » Sat May 21, 2016 9:57 am

I have a flashlight underneath it I have placed a sprite to simulate the light beam (triangle sprite with reduced opacity of yellow color).
The problem is, if I copy my flashlight without cloning/creating new object, how can I make it have this light beam also?
For example, If i'll add drag and drop on my flashlight, whenever I move my flashlight its light cone must move with it.

I hope this will illustrate it
Image

At the moment the only option I see is using frames, one without the lightbeam and one with, and switch between them. :lol:
B
11
S
3
Posts: 44
Reputation: 713

Post » Sat May 21, 2016 10:08 am

everytick = lightbeam.setangle-to:flashlight.angle that should solve it

or you can use the pin behavior on light and pin it position&angle and will automatically follow the flashalight angle and position.

here is a capx example v2 using pin

i updated the toggle of the lightbeam now when you press the flashlight from button to the tail area it toggles the opacity of the lightbeam sprite.
B
76
S
22
G
69
Posts: 1,353
Reputation: 43,833

Post » Sat May 21, 2016 10:21 am

And if you want to copy the flashlight and have the new one also have its own beam, use containers :D https://www.scirra.com/manual/150/containers
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 205
Reputation: 3,468

Post » Sat May 21, 2016 1:47 pm

gamecorpstudio wrote:everytick = lightbeam.setangle-to:flashlight.angle that should solve it

or you can use the pin behavior on light and pin it position&angle and will automatically follow the flashalight angle and position.

here is a capx example v2 using pin

i updated the toggle of the lightbeam now when you press the flashlight from button to the tail area it toggles the opacity of the lightbeam sprite.


Thanks but I wanted to achieve something a bit different. As for now you have a flashlight and light beam, what I wanted is to use the same lightbeam on other copies of flashlight, like for example, If i copy the flashlight, set it to rotate by a bit different curve but use the same lightbeam on it. Such as, it moves differently, but light the same.

mikehive wrote:And if you want to copy the flashlight and have the new one also have its own beam, use containers :D https://www.scirra.com/manual/150/containers


According to the manual this approach creates same object, but I can't manipulate each one of the created objects separately. I would like to animate the flashlight, or change its position independently of all other flashlights.
B
11
S
3
Posts: 44
Reputation: 713

Post » Sat May 21, 2016 1:53 pm

Using gamecorpstudio's example, click on the Flashlight, create a container and add the Lightbeam. Make two more copies of the Flashlight. Done!
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Sat May 21, 2016 2:36 pm

blackhornet wrote:Using gamecorpstudio's example, click on the Flashlight, create a container and add the Lightbeam. Make two more copies of the Flashlight. Done!

Thanks, that's what I've been looking for.
B
11
S
3
Posts: 44
Reputation: 713


Return to How do I....?

Who is online

Users browsing this forum: ditocruz, uzumiapps and 28 guests