How do i move a sprite with the left stick?
-
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 -
Hi - welcome to the Arena!
There is an example of exactly this in the help tutorials:
https://fuzearena.com/help/view/Sprite GameAbout 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.
-
You could also use the sprite properties to do this. Doing
setSpriteSpeed( sprite, speed )
is exactly the same assprite.x_speed = speed
andsprite.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
-
@Dave thanks a bunch!