Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How do i move a sprite with the left stick?

    Beginners
    help screen sprites
    3
    4
    424
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      smoof1738 last edited by

      Need help with moving a sprite around with the left stick
      I usually do setspritespeed(sprite, speed) and i have a speed vector that's modified by the control stick. That doesnt move the sprite though, even with the help of updatesprites()
      I've been trying to deal with this for like 2 days now so i'd appreciate some help

      1 Reply Last reply Reply Quote 2
      • Martin
        Martin Fuze Team last edited by

        Hi - welcome to the Arena!

        There is an example of exactly this in the help tutorials:
        https://fuzearena.com/help/view/Sprite Game

        About a third of the way down the page there is a line "Now let's apply some controls:" and it introduces modifying the velocity of the sprite by the left control stick.

        1 Reply Last reply Reply Quote 3
        • Dave
          Dave Fuze Team last edited by

          You could also use the sprite properties to do this. Doing setSpriteSpeed( sprite, speed ) is exactly the same as sprite.x_speed = speed and sprite.y_speed = speed.

          Make sure you're reading the controllers in the loop:

          loop
              clear()
              c = controls(0)
          
              sprite.x_speed += c.lx
              sprite.y_speed -= c.ly // we use -= because of the screen dimensions to make it move properly on the y axis, otherwise down on the stick will move upwards.
          
              // apply a deceleration - the 0.9 is the rate of slowdown. Numbers closer to 1 will result in longer deceleration.
              sprite.x_speed *= 0.9
              sprite.y_speed *= 0.9 
          
              updateSprites()
              drawSprites()
          repeat
          
          S 1 Reply Last reply Reply Quote 1
          • S
            smoof1738 @Dave last edited by

            @Dave thanks a bunch!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post