report location of hex coordinate on tap

This commit is contained in:
Gavin McDonald
2016-03-05 20:48:18 -05:00
parent 7bb085557e
commit 839971a8c0
3 changed files with 28 additions and 25 deletions

View File

@@ -7,13 +7,13 @@ import {Cell} from './tessellate.js';
class Demo {
constructor() {
['click', 'draw'].map(method => this[method] = this[method].bind(this));
['onTap', 'draw'].map(method => this[method] = this[method].bind(this));
this.map = [];
let tessellate = new Tessellate({
element: '#container',
click: this.click,
tap: this.onTap,
draw: this.draw
});
@@ -25,16 +25,16 @@ class Demo {
this.styles = ['filled', 'outline'];
}
click(event) {
let x = event.pageX;
let y = event.pageY;
onTap(tap) {
let scale = utils.random(10, 50);
console.log(tap.hex.getHex());
this.map.push(new Cell({
tile: this.tiles[utils.random(this.tiles.length-1)],
style: this.styles[utils.random(this.styles.length-1)],
x,
y,
x: tap.point.x,
y: tap.point.y,
scale,
pointyTop: utils.random(1) ? true : false,
red: utils.random(255),