I have a HTML Button (div) and i want to create a touch event on it.
At the moment the tap/click works only if I click on the screen NOT the button.
It’s clearly because of this.app.touch.on(“touchstart”, this.onTouchDown, this);
How can I change this, so “TouchDown” starts when i only press the HTML Button?
Any ideas?
The code from this project did not work for me PlayCanvas 3D HTML5 Game Engine
And I can’t get the div with: var button = this.element.querySelector(‘#ButtonUp’);
THX
Button.prototype.initialize = function() {
// create DIV element
var div = document.createElement(“div”);
this.element = div;
div.id = “ButtonUp”;
div.innerHTML = this.html.resource;
document.body.appendChild(div);
Hi, MadOrb.
I think if you use HTML Button, you’d better using JavaScript’s event instead of PlayCanvas. Something like that element.addEventListener('click', function(){ //do stuff }, false);
It’s simpler with the eventListener and the click function.
Wrong search the whole time but now i found this and after some changes it works well for me