Actor/Particles help - Laser Beam - how to control size with power bar
dandandan18
Member Posts: 35
Hi,
I want to use a laser beam in my app.
I have 2 ways of doing this. I'd rather use the first way but it may be hard to do - I can't figure it out.
1. There will be a power bar on the side so the user can change the 'power'/distance of the laser beam.
I will make the laser beam in Adobe After effects, but I'm not sure how to import it into GS – I was thinking of just making PNG's of different sized laser beams.
I don't want to just change the size of the laser beam as that may make it blurry scaling it down in GS.
2. My other way how to do this is to create a 'trigger'/shoot button so it shoots a laser beam at the actors but not like a bullet how it's only one bullet at a time, but a 'full' laser beam that fires till the end of the screen. If any actors are in the way of fire it will change size so it hits the front of the actor and doesn't go through the actor and till the end of the screen still if you know what I mean.
- was thinking of using particles to do this?
Any ideas on how to do this?
I really appreciate your help
I want to use a laser beam in my app.
I have 2 ways of doing this. I'd rather use the first way but it may be hard to do - I can't figure it out.
1. There will be a power bar on the side so the user can change the 'power'/distance of the laser beam.
I will make the laser beam in Adobe After effects, but I'm not sure how to import it into GS – I was thinking of just making PNG's of different sized laser beams.
I don't want to just change the size of the laser beam as that may make it blurry scaling it down in GS.
2. My other way how to do this is to create a 'trigger'/shoot button so it shoots a laser beam at the actors but not like a bullet how it's only one bullet at a time, but a 'full' laser beam that fires till the end of the screen. If any actors are in the way of fire it will change size so it hits the front of the actor and doesn't go through the actor and till the end of the screen still if you know what I mean.
- was thinking of using particles to do this?
Any ideas on how to do this?
I really appreciate your help
Comments
...1. If the power bar is on full and it comes into contact with an actor the laser beam will resize (less power) to hit the actor
With that created, and the button only moving between two points on a slider you can work out the power based on how high it is up the slider, using percentages.
For shooting the laser you could have it extend from the gun, growing in size and when it hits the first enemy (if actor collided with enemy) it stops growing. That should stop it from going through to enemies behind the first.
You can still make it grow based on the power used and have it stop if it hits an enemy before it's grown to the maximum size it can, based on its power.
Try building the slider first and getting it to the point where you can display a power number, before you add in the laser.
Place two enemies on the laser and it will stop at the first one until you move the first one away.
You'll have to figure out how to connect your power bar/slider with the laser so that the maximum width (currently 450) is the maximum width the power will allow.
https://www.dropbox.com/s/79u38cu3m5qmn7g/laser ONE v2.png
I want the top head of the laser not to be scaled about, if I could just make the bottom bit be cut off then that's okay.
Hope this helps, let me know what you need or if you are confused.
If you do go with my script then try what @NovicaStudio says and split the image into two, and have your code put the sparks bit at the end of the line when it collides with something.
@KevinCross yeah I'll use your file to make it but under the timer when I turn the second change attribute off the laser beam starts off small and extends till the end which is what I want but when it resets it goes to the bottom and doesn't start off small and extend again, might have to create a reset behaviour or something?
Btw, how do you type in self.Original X in the change attribute? I want to make it go up to the Y axis not left but whenever I replace it with a Y and the Self.Position.X into Y it doessn't work for some reason - doesn't go blue even though it's typed in.
This is my first App so I'm still learning things. Thanks for your help patience guys I really do appreciate it
Click on you actor name from the list in the expression window, then click on position, and then either X or Y.
it's not there for some reason
If you like attribute names without spaces then add it as originalX or origX. Use whatever name you prefer
Here's the file https://www.dropbox.com/s/wbdw1eikhgq5egw/Laser - GS.zip
if the 'laser beam 3' image doesnt' appear heres the link - https://www.dropbox.com/s/xsurgzpdgi7zqo5/laser beam 3.png
The laser on the bottom that fires to the left is the one from the file @kevincross uploaded, I just changed it to Portrait mode so it kind of messed up.
Basically I want to link the slider height with the height of the laser beam (image - laser beam 3), using a constraint attribute and percentages - a certain percentage of movement on the slider corrolates to a larger percentage movement of the laser.
At the moment the laser is at its full beam so the slider will be at 100% - as high as it can go (watch in Preview mode to see).
I'm not sure how to go about doing this to be honest as it's my first app, I've googled around and still unsure. I've read the GS manual etc too but cant seem to do it.
Also - I don't want the laser beam to keep on resizing itself once it reaches the top like the red laser - i want the laser power / Y axis size (height) to be controlled by the slider bar.
I'm happy to make Adobe Illustrator Artwork for an app if anyone can help me resolve this soon as my gamesalad skills aren't that good atm.
2) In the slider actor add the following constrain behavior:
Constrain Attribute: game.Power To: self.Position.Y - self.slider min
3) In the laser BEAM 3 actor add the following constrain behavior:
Constrain self.Position.Y To: (6*game.Power-( self.Size.Height/2))
That should get things started!
At first the laser was still appearing in preview mode but when I moved the slider it didn't change the height of the laser - the laser was immobile.
Now i've moved the slider position around when I click preview the laser doesn't even appear.
What'd you think?
Been playing around with the numbers in the Laser Beam 3 Constraint Attribute (6*... height/2) and it doesnt seem to make a difference
The laser beam constrain behavior does not change the "height". Instead it changes the y position of the actor.
How would I get the Laser beam to change Y position when it collides with an actor. - The actors move down the screen, I want the laser to move along with it as it will take a few seconds to destroy the actor
Guess i'll have to make a rule when - laser beam comes into contact with actor something something.... Actor Position Y - Laser beam position Y?
As I said before, I'm happy to do some artwork if you need any
2.Made a Constraint attribute on my enemy -
Game.Enemy to Self.Position.Y
3. Made a Rule on the Laser beam 3 -
Actor receives event - overlaps or collides with actor of type - *Enemy name*
But, when I click preview when the Laser beam 3 is in contact with the enemy the laser flashes on and off, the bottom half of the laser starts to regrow but it doesnt work.
After the enemy is killed the laser beam should resize then back to the size from the slider.
I can upload it to youtube if you would like..
If Laser beam 3 collides with an enemy
-- move laser beam down at the same rate the enemy is moving down
-- after a certain short time period, destroy the laser beam actor
otherwise
-- move the laser bean up to match the slider's power value
If LaserBeam collides with an enemy
-- Store the difference between the two actors in an attribute: difference=(enemy.Y-laser.Y)
-- constrain the laser.Y to (enemy.Y+difference)
-- after a certain short time period, destroy the laser beam actor
otherwise
-- move the laser bean up to match the slider's power value