Skip to content

Commit

Permalink
Touch zoom working (not in the best way)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateosss committed Sep 1, 2016
1 parent 03558ab commit 19a0afe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Extras/horarios.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Mi 31
- Arreglar compilacion para android botones tactiles, despues de 8 horas - 30 min
- Resolucion adaptable y pantalla completa en android - 1:50
- En game over la aplicacion se cierra - 0:45 hs
- arreglar zoom con dos dedos y scrollmap tactil - 21:00
- arreglar zoom con dos dedos - 21:00
- explicacion del juego y posteo en reddit
- Despues de ganar/perder no se pueden poner torres NO SOLUCIONADO- 1:40 hs

Expand Down
22 changes: 10 additions & 12 deletions src/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,16 @@ var Level = cc.LayerGradient.extend({ // TODO Ir archivando historial de oleadas
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesMoved: function (touches, event) {
// TODO hacer padre que tenga moveButton, zoomButton map y herede aca
// TODO Update pasarlo al map, por que update cosas suyas
this.map = event.getCurrentTarget().map;
var touch = touches[0];
var delta = touch.getDelta();
// this.map.moveMap(delta.x, delta.y);
this.map.positionTarget.x += delta.x;
this.map.positionTarget.y += delta.y;
this.map.moveMap(delta.x, delta.y);
if (touches.length > 1) {
zoomDelta = delta.y*0.001;
//TODO make a good zoom method for gods sake
var initialDistance = cc.pDistance(touches[0].getStartLocation(), touches[1].getStartLocation());
var currentDistance = cc.pDistance(touches[0].getLocation(), touches[1].getLocation());
var zoomDelta = (currentDistance - initialDistance) * 0.0001;
this.map.zoomMap(zoomDelta);
// zoom = this.map.scale + zoomDelta;
// if (zoom >= 0.15 && zoom <= 1.0) {
// this.map.scale = zoom;
// }
}
}
}, this);
Expand All @@ -170,12 +165,15 @@ var Level = cc.LayerGradient.extend({ // TODO Ir archivando historial de oleadas
}
else if(this.pressed == this.zoomButton) {
var zoomDelta = event.getDelta().y * 0.001;
console.log(zoomDelta);
this.map.zoomMap(zoomDelta);
}
}
},
onMouseScroll: function(event) {
console.info("scroll");
this.map = event.getCurrentTarget().map;
var zoomDelta = event.getScrollY() * 0.0001;
this.map.zoomMap(zoomDelta);
},
}, this);
}
Expand Down Expand Up @@ -300,7 +298,7 @@ var Level = cc.LayerGradient.extend({ // TODO Ir archivando historial de oleadas
crossover: function(p1, p2, sonsCount) { //TODO GA que el robot sea equilibrado
// Crossovers two DNAs from robot.getDNA(), p1 is the strongest parent
sonsCount = sonsCount || 2;
var possible = [
var possible = [//TODO hardcoded
[0, 1, 2], //pTurnProb
[0, 1, 2], //pLife
["electric", "fire", "water"], //pElement
Expand Down

0 comments on commit 19a0afe

Please sign in to comment.