nativescript-joystick
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -52,3 +52,3 @@ "use strict"; | ||
// Update the observable attributes | ||
_this.updateAttributes(x, y); | ||
_this.updateAttributes(x * 100, -y * 100); | ||
}; | ||
@@ -72,6 +72,7 @@ }; | ||
JoyStick.prototype.calculatePower = function (x, y) { | ||
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); | ||
var power = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); | ||
return (power > 100) ? 100 : power; | ||
}; | ||
JoyStick.prototype.calculateAngle = function (x, y) { | ||
return Math.atan2(-y, -x) * 180 / Math.PI; | ||
return Math.atan2(y, -x) * 180 / Math.PI; | ||
}; | ||
@@ -78,0 +79,0 @@ JoyStick.prototype.updatePadColor = function (color) { |
{ | ||
"name": "nativescript-joystick", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "NativeScript XML plugin to create native JoyStick widget.", | ||
@@ -5,0 +5,0 @@ "main": "joystick.js", |
# NativeScript-JoyStick | ||
An Android UI component for NativeScript that provides Virtual JoyStick | ||
Hopefully I will be able to add iOS soon. | ||
An Android and iOS UI component for NativeScript that provides Virtual JoyStick | ||
![Sample](screens/joystick.png) | ||
![Sample Android](screens/joystick-android.png)![Sample iOS](screens/joystick-ios.gif) | ||
## Native Source | ||
### Android | ||
This component is based on [JoyStick component from AndroidArsenal](https://android-arsenal.com/details/1/2712) created by [erz05](https://github.com/erz05) | ||
### iOS | ||
This component is based on [JoyStick component from cocoapods](https://cocoapods.org/pods/CDJoystick) created by [Cole Dunsby](https://cocoapods.org/owners/9940) | ||
And then modified to work better with Objective C, into [JoyStick another cocoapod](https://cocoapods.org/pods/CCDJoystick) by [tzraikov](https://github.com/tzraikov) | ||
## Installation | ||
@@ -25,2 +29,4 @@ From your command prompt/termial go to your app's root folder and execute: | ||
<Label text="{{'Power:' + power}}" textWrap="true" /> | ||
<Label text="{{'Horizontal:' + horizontal}}" textWrap="true" /> | ||
<Label text="{{'Vertical:' + vertical}}" textWrap="true" /> | ||
@@ -27,0 +33,0 @@ <js:JoyStick |
17758
333
76