Giter Site home page Giter Site logo

joystick's Introduction

Joystick

Cocos Creator 游戏摇杆(全方向、四方形、八方向、跟随模式)。

Screenshot

Feature

  • 多类型选择(全方向、四方形、八方向)
  • 跟随模式

Usage

步骤:

  1. 拷贝 Joystick.js 文件到您的项目中,并作为用户脚本组件添加到您项目的摇杆节点。
  2. 根据项目需求指定 Joystick 组件的属性。
    Joystick
  3. 通过摇杆控制角色,具体查看Tank.jsPlayer Script

具体使用方法请下载本项目在 Cocos Creator 中查看。

动态修改摇杆类型

方式1(代码修改):

var Joystick = require('Joystick');

// 省略代码,有 Joystick 组件实例(命名 joystick )。

this.joystick.setType(Joystick.Type.ALL);

方式2(编辑器指定事件回调函数):

Joystick 组件中已编写了函数作为事件回调,在编辑器中直接使用即可。

回调函数:setTypeAsAll() setTypeAsFour() setTypeAsEight()

动态修改是否使用跟随模式

方式1(代码指定):

var Joystick = require('Joystick');

// 省略代码,有 Joystick 组件实例(命名 joystick )。

var isFollow = true; // or false
this.joystick.setFollow (isFollow);

方式2(编辑器指定事件回调函数):

Joystick 组件中已编写了 toggleFollow() 函数作为事件回调,在编辑器中直接使用即可。

joystick's People

Contributors

shichaohui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.