VirtualJoystickRegion 虚拟摇杆插件
It solves many problems you face when trying to code a joystick, so if you are learning about it you may want to take a look. Also it is somewhat resolution independant so you dont have to worry about adjusting its size neither position.
This sample works within a "region" of the screen where the joystick adjusts its position to the player's finger if he taps inside that region.
It also work inside a circular boundary instead of a square and it can detect double taps too.
It does not use OnGUI(), its GUItextures and it does not need collision detection to work; very simple to use:
1) Create an empty Game Object.
2) Add the VirtualJoystickRegion.cs script to that object.
3) Use square textures for the "Joytick 2D" and "Background 2D" fields.
4) Adjust the "Active Color" and "Inactive Color" values as you wish, and its ready to go.
Note:
The Joystick outputs two global variables for you to work with, VJRvector and VJRnormals.
To get real screen space values, you query "VirtualJoystickRegion.VJRvector".
To get normalized joystick values, ideal numbers to work with, you query "VirtualJoystickRegion.VJRnormals".
If you dont like big names you may want to rename the "VirtualJoystickRegion" class to just "VJR".
哇 好厉害噢{:5_397:} 是啊,好厉害 谢谢分享了{:5_404:}
也不能一竿子打死呀!{:soso__11174995096617402082_3:} 真心顶 说的非常好 很好哦 不错不错 LZ真是人才
页:
[1]