Actor/Particles help - Laser Beam - how to control size with power bar

dandandan18dandandan18 Member Posts: 35
edited September 2013 in Working with GS (Mac)
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
«1

Comments

  • dandandan18dandandan18 Member Posts: 35
    forgot to add abit onto 1.

    ...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
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    I don't know how you're changing the power bar but if you're going to set it up like a slider then you need to look at constraining an actor along one axis and between two points, so if it's a vertical slider you'd constrain its x position to one place. The actor would have an if touch/mouse pressed/released rule on it and in that rule you want to constrain the y position to your mouse.position.y. I mentioned between two points because you don't want the button on the slider (forgot what the correct term is) to move to the top and bottom of the screen.

    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.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    This probably isn't the best way of doing it as it seems a little laggy but here's a project where the laser grows every 0.1 seconds by 15px until it reaches 450 or collides with an enemy. You can drag the enemy (green boxes) around the scene and in front of the laser where it will stop.

    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.
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    @KevinCross Been working on this for a bit. When I added the image of the laser beam to the laser it just stretched it out and didn't look right at all...
  • dandandan18dandandan18 Member Posts: 35
    forgot to mention that I made the slider (working on the y axis)
  • dandandan18dandandan18 Member Posts: 35
    I'm not sure that using percentages is the best way to do it because it may make my laser blurry. Heres an image of the laser -

    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.

  • dandandan18dandandan18 Member Posts: 35
    bump
  • NovicaStudioNovicaStudio Member Posts: 174
    Split the drawing into two .png files. One for the little 'sparks' coming right off of the shooter, and one for the laser itself. Looking at your image, after the sparks, it would look the same being resized. If power is ___ and it is shot, then show the laser spark image, and then you can make some sort of equation that shows the laser and the size of it.

    Hope this helps, let me know what you need or if you are confused.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Sometimes/more often than not I throw things together in GameSalad which probably aren't the best way to tackle the problem, but it'll be one way of doing it and how I might do it until I found a better way. There's probably a dozen other ways to get what you want so keep at it and you'll hopefully find one.

    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.
  • dandandan18dandandan18 Member Posts: 35
    thanks @NovicaStudio i'll try that... was thinking of having a smaller head when it doesnt collide and making it more 'streamline' - like making the spikes more inward.


    @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
  • dandandan18dandandan18 Member Posts: 35
    i've found this but I don't think it really applies - http://forums.gamesalad.com/discussion/5421/power-meter
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    You can't type self.Position.X in the expression box you have to select it from the expression window/menu. Typing won't work unfortunately. Things would be much quicker if you could.

    Click on you actor name from the list in the expression window, then click on position, and then either X or Y.
  • dandandan18dandandan18 Member Posts: 35
    @NovicaStudio I still think that using percentages isn't the best way as I dont want to be resizing the image even if it is the bottom half it still loses clarity when i resize the beam (not sparks) in gamesalad
  • dandandan18dandandan18 Member Posts: 35
    @kevincross yeah I tried the expression with the self position but how did you do 'self original X'? - that's the one i typed in
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    If you're using my template original X will be in the same list where position is but at the bottom of it. I'll take a screenie in a mo when I'm on my computer
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Here's the screenshot

    image
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Ok looking at that you're using your own project which means you haven't added the attribute to the laser. If you look at mine you'll see I've added an attribute to the laser actor called Original X. Add that to yours too and you'll see it in the list

    If you like attribute names without spaces then add it as originalX or origX. Use whatever name you prefer
  • dandandan18dandandan18 Member Posts: 35
    was just thinking...by splitting the images into 2, could I do what I want by using the slider to control the accelerate amount. If I make the laser beam over the screen height (in portrait mode) then just fire it from the back of the gun will this work/be efficient?
  • dandandan18dandandan18 Member Posts: 35
    still no progress :((
  • dandandan18dandandan18 Member Posts: 35
    Been busy for past 2 days so haven't got much done but I'm back to full time now for another week so need to get this laser thing sorted out over the next day or so really.
    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.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    1) Make a game level attribute (type = real) and name it "Power".

    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!
  • dandandan18dandandan18 Member Posts: 35
    @RThurman Thanks, I've done that.
    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?
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    just realised I used a change attribute on part 3 instead of constrain which is why it wouldn't change in preview. BUT in the preview mode when i move the slider up and down it doesn't change the laser height too....

    Been playing around with the numbers in the Laser Beam 3 Constraint Attribute (6*... height/2) and it doesnt seem to make a difference
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Keep working on it! You will get it.

    The laser beam constrain behavior does not change the "height". Instead it changes the y position of the actor.
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    @RThurman thanks a lot, i've got it working now

    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 :)
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    1. I've made a new Real Game Attribute called enemy.

    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..
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited September 2013
    So it sounds like what you are saying is something like this:

    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
  • dandandan18dandandan18 Member Posts: 35
    @RThurman yes that's exactly what I want to do but i was having problems with it moving down at the same rate as the enemy (which is accelerating)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    How about something like this:

    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
Sign In or Register to comment.