# # 工欲善其事, its prerequisite
Sometimes it's important to learn how to apply third-party libraries, because we don't have to reinvent our own wheels, and here we use gravity sensing to manipulate the plane instead of using joystick joystick to manipulate it as follows:
```
Statement game joystick;
private Var joystick:analogjoystick! Game joystick;
```
> Create a function, new game joystick node, and add to Gamescene
```
mark:-//adding gamepad
Func Createjoystick () {
Joystick = Analogjoystick (Diameter:cgfloat (250.0))//joystick diameter
Joystick.stick.image = UIImage (named: "Jstick")//Joystick diagram
Joystick.substrate.image = UIImage (named: "Jsubstrate")//joystick background
Joystick.zposition = 1
Joystick.position = Cgpoint (x: -380.0, y:-720.0)
Self.addchild (Joystick)
Joystick.alpha = 0.8
Control just started.
Joystick.beginhandler = {[unowned self] in
Guard Let Sprite = Self.playernode else {
Return
}
Print ("Begin", Sprite);
}
Tracking controls
Joystick.trackinghandler = {[unowned self] data in
Guard Let Sprite = Self.playernode else {
Return
}
Let x = data.velocity.x * 0.12
Let y = data.velocity.y * 0.12
Let XPos = sprite.position.x + x
Let YPos = sprite.position.y + y
Sprite.position = Cgpoint (X:xpos, Y:ypos)//Update aircraft location
Sprite.zrotation = data.angular//aircraft angle steering;
}
When the joystick is stopped;
Joystick.stophandler = {[unowned self] in
Guard Let Sprite = Self.playernode else {
Return
}
Print ("Stop", Sprite);
}
}
```
> Add joystick function to the override Func Didmove (to View:skview) {}
```
Game Handle Start
Override Func Didmove (to View:skview) {
Createjoystick ()
}
```
Just take these steps above, you can add cool game joystick, it's so simple!!!
Game Teaching: http://www.iFIERO.com
SOURCE Portal: Https://github.com/apiapia/SpaceBattleSpriteKitGame
Spritekit mobile game joystick joystick use--by Ifiero game development tutorial