Skip to content

Latest commit

 

History

History
102 lines (70 loc) · 5.18 KB

README.en.md

File metadata and controls

102 lines (70 loc) · 5.18 KB

cocos-creator-joystick

Cocos Creator Joystick Demo

GitHub release (latest by date) Cocos Creator version GitHub top language GitHub code size in bytes

中文文档 | English Docs

Online Preview: cocos-creator-joystick

Usage

Downoload

Releases

By import

Cocos Creator v3.x -> File -> Export assets ... -> Choose -> assets/demo.fire Cocos Creator v3.x -> File -> Import assets ...

By git

git clone https://github.com/YunYouJun/cocos-creator-joystick.git

Open with Cocos Creator 3.x.

You can see it in demo.fire scene.

Go through the main menu Developer -> VS Code Workflow -> Update VS Code API Source to complete the update about creator.d.ts.

Function

  • Joystick Type
    • Fixed
    • Follow
  • Player
    • rotation
    • move
  • Touch Place (custom Joystick width and height)
    • Full Screen
    • Half Screen
  • Decoupling between nodes (only need to monitor Touch events, without mounting the Player node to Joystick, can control many Players)

Joystick

Argument Type Default Description Customizable
joystickType JoystickType.FIXED / JoystickType.FOLLOW JoystickType.FIXED types of joystick
ring cc.Node - joystick background node
dot cc.Node - joystick control node

Player

Argument Type Default Description Controled by Joystick Customizable
rigidbody boolean false Rigidbody (Physics) mode × x
moveDir Vec2 cc.v2(0, 1) // straight up initial direction of movement
_speedType SpeedType.STOP / SpeedType.NORMAL / SpeedType.FAST SpeedType.NORMAL speed type ×
_moveSpeed cc.Integer 0 speed of movement × ×
stopSpeed cc.Integer 0 speed when stop ×
normalSpeed cc.Integer 100 normal speed ×
fastSpeed cc.Integer 200 fast speed ×

Structure

assets/script

Filename Description Function
Joystick.js Joystick Script store joystick main logic (include some type definitions and global events listen)
Player.js Player Script listen events emitted by Joystick (You can customize it.)
UI.js UI provide switch joystick type function for online preview(You can delete it directly if you don't need it.)

Other

Star, Issues and Pull requests are welcome.

Recommended coding standards

Dev

Build

npm run build

Deploy

npm run deploy