Coder Social home page Coder Social logo

joystickmodule's Introduction

JoyStick

基于LayaAir的简单虚拟摇杆模块

在线Demo

在线Demo

基本用法

var j = new JoyStick();
j.pos(0, Laya.stage.height-400);
j.setTouchSize(Laya.stage.width/2, 400);
j.setOriginPos(150, 150);
j.setImg('joystick/button.png','joystick/background.png','joystick/arrow.png');
j.fixRadius();
j.on('move',this,function(angle,rad){
    console.log(angle,rad);
});
Laya.stage.addChild(j);

完整用法

var j = new JoyStick();
j.pos(0, 300);
j.autoAlpha = true;//自动半透明.默认true
j.joystickAlpha = 0.4;//半透明值.默认0.4
j.fixedPosition = true;//固定位置.默认true
j.setRadius(100);//设置半径.默认100
j.setTouchSize(Laya.stage.width, 500);//设置可触摸区域.默认全屏
j.setOriginPos(Laya.stage.width/3, 250);//设置摇杆起始位置.默认正中
j.setImg('joystick/button.png','joystick/background.png','joystick/arrow.png');//设置图片
j.fixRadius();//修正半径
j.setDebug(true);//开启调试.默认不开启
j.on('down',this,function(){//按下监听
});
j.on('move',this,function(angle,rad){//滑动中监听
    console.log(angle,rad);
});
j.on('up',this,function(){//抬起监听
});
Laya.stage.addChild(j);

joystickmodule's People

Contributors

watermelon-xci avatar

Stargazers

 avatar  avatar  avatar

Forkers

elfhash

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.