report location of hex coordinate on tap
This commit is contained in:
14
src/main.js
14
src/main.js
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user