Help with BIRD flight controls!

CuckooheadCuckoohead Member Posts: 16
edited November -1 in Working with GS (Mac)
I'm trying to create a bird character that moves according to different types of touch. The bird inside my game will be accelerating forward at a fixed speed, the only control you have over its movement is to make it fly higher, go down, and dive. To make the bird fly higher you have to tap repeatedly on the screen. Each tap makes the bird move up a small amount, and when you are not tapping the bird begins to fall toward the ground. When you tap and hold, the bird dives rapidly downward until you release.

So, to summarize what I need help with:

1. Creating a rule that causes the bird to move up a fixed distance when the screen is tapped anywhere in the scene (I want the player to have to tap rapidly in order to get the bird to get really high).
2. Creating gravity that makes the bird fall down slowly when not being tapped or pressed.
3. Creating a rule, when touch is held, that causes the bird to plunge/dive downwards until touch is released (and not get confused with being tapped. Tap = up, press-and-hold = dive).

If anyone could help give me an idea of the most efficient way to create these controls, please do! Your advice is greatly valued :)

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    1) create a self boolean attribute (call it self.Dive)

    In the bird have this rule (all) -
    When mouse is down
    When self.dive is False
    ______change self.linear.velocity.Y to ??? (some positive number)
    Timer After .5 seconds (DO NOT check run to completion)
    _____change self.dive to 1

    2) In the bird put an accelerate at 270 to scene.

    3) When self.dive is true, accelerate 270 to scene.

    rule when mouse is up change self.dive to false
  • SkyMapleSkyMaple Member Posts: 817
    make a new invisible actor that covers the screen
    Add a new global attribute called "Direction" (integer)

    In that actor make a rule

    Rule-If touch is released
    change attribute "Direction" to 1

    Rule If touch is pressed
    change attribute "direction" to 2
    Timer after 0.1 (DONT run to completion)- change attribute "Direction" to 3

    This way if direction is 1-fall 2-rise 3-Dive

    on the bird make a rule

    Rule if attribute "Direction" is 1
    Change velocity to down at 100speed

    Rule If attribute "direction" is 2
    Change attribute "self.linear velocity.Y" to +10

    Rule If attribute "Direction" is 3
    change Velocity to down at 400speed
  • CuckooheadCuckoohead Member Posts: 16
    Wow, thanks guys for your quick responses! I'll try both your ways out and let you know how they worked :D
Sign In or Register to comment.