mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Added Swiper drawing
This commit is contained in:
parent
cf2182676b
commit
1e233efbea
6 changed files with 85 additions and 7 deletions
|
|
@ -104,7 +104,6 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
|
|||
|
||||
canvas.onmouseup = function(e) {
|
||||
if(self.swiper) {
|
||||
console.log(e)
|
||||
var xya = self.swiper.swipeEnd(e.x, e.y);
|
||||
self.playerController.handActionRequest(xya.x, xya.y);
|
||||
self.swiper = null;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
define([
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
],
|
||||
|
||||
function () {
|
||||
function (Nc) {
|
||||
|
||||
var MAX_LENGTH = 300;
|
||||
var MAX_LENGTH = 150;
|
||||
|
||||
function Swiper() {
|
||||
this.points = [];
|
||||
|
|
@ -12,11 +13,14 @@ function () {
|
|||
}
|
||||
|
||||
Swiper.prototype.swipe = function(x, y) {
|
||||
console.log("swipe")
|
||||
|
||||
|
||||
if(this.lengthSum > MAX_LENGTH) return;
|
||||
|
||||
this.points.push({x:x, y:y});
|
||||
|
||||
Nc.trigger(Nc.ns.client.view.swiper.swipe, x, y);
|
||||
|
||||
var points = this.points;
|
||||
|
||||
if(points.length >= 3) {
|
||||
|
|
@ -77,6 +81,8 @@ function () {
|
|||
var p0y = this.points[0].y;
|
||||
var sumx = 0;
|
||||
var sumy = 0;
|
||||
|
||||
Nc.trigger(Nc.ns.client.view.swiper.end);
|
||||
|
||||
for(var i=0, count = this.points.length; i < count; i++) {
|
||||
var p = this.points[i];
|
||||
|
|
@ -103,6 +109,12 @@ function () {
|
|||
spin: spin
|
||||
}
|
||||
}
|
||||
|
||||
Swiper.prototype.destroy = function() {
|
||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||
Nc.off(this.ncTokens[i]);
|
||||
};
|
||||
};
|
||||
|
||||
return Swiper;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue