how to make a cannon variable fire strength

tollhousestudiotollhousestudio Member Posts: 166
edited November -1 in Working with GS (Mac)
what I'm trying to do is create a cannon, with a bar that moves up and down and when you tap, it fires at the strength that is in the bar.

Does that make sense?

not hold down to get whatever strength you want, tap to try and catch it at full strength.

This would be tasty if you could help.

Comments

  • EastboundEastbound Member, BASIC Posts: 1,074
    Yeah you just have a global variable for power = 0, and on the meter item have a boolean named up and set to true.

    Every .01 seconds set power + 1 if up is true, and power - 1 if up is false.
    Also check that if power >= 100, set up to false, and if power <= 0, set up to true.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hey,

    so you will need 4 attributes in the bar Actor:

    minHeight
    maxHeight
    scaleDirection
    scaleSpeed

    enter in the minimum Height of the bar, as well as the maximum height (these are in pixels)
    scale Direction will be an integer, either 1 or -1, set it initially to 1
    scale speed is the speed in which the bar grows/contracts, play with this setting until you like it.

    Create a timer:

    EVERY 0.01 seconds
    Change Attribute: self.Size.Height To: self.Size.Height + (self.scaleSpeed * self.scaleDirection)

    Create two Rules:

    When self.Size.Height >= self.maxHeight
    Change Attribute: self.ScaleDirection To: -1

    When self.Size.Height <= self.minHeight
    Change Attribute: self.ScaleDirection To: 1

    Finally, within the Timer, you will put another Change Attribute.
    This is where you will set your global game attribute called "power" or whatever.
    Set this to be some ratio of the height of the bar, or just the height itself.

    Hope this helps!
    Joe
  • tollhousestudiotollhousestudio Member Posts: 166
    Is there any demo projects of this sort of thing, I can't find any.

    I'm kinda struggling.
Sign In or Register to comment.