Advanced Joystick is a class that creates a virtualÂ joystick forÂ Starling. Every frame it calculates the position of the stick and translateÂ those values toÂ
velocityY,Â both as normalized values, meaning they are between -1 and 1.
It has a default skin for the stick and its holder, but it’s possible to replace them with custom graphics at runtime.
import starling.extensions.advancedjoystick.JoyStick; var myJoystick:Joystick = new Joystick(); myJoystick.setPosition(myJoystick.minOffsetX, clientHeight - myJoystick.minOffsetY); addChild(myJoystick); ... player.x += myJoystick.velocityX * maxSpeed; player.y += myJoystick.velocityY * maxSpeed;
Huyhung Kun liked this on Facebook.