Making my web app mobile compatible

I am trying to create an app that works both on a computer and a phone. The app works well on a computer but the buttons do not respond on a mobile device.

I am using this code for the buttons to respond:

this.entity.element.on('mousedown',this.onMouseDown,this)

What is the format of the code to make it respond to touches. I tried this:

this.entity.element.on(pc.EVENT_TOUCHSTART,this.onMouseDown,this)

Nothing happens.
Please help

Try this:

// touch events
this.entity.element.on('touchstart', this.onPress, this);
this.entity.element.on('touchend', this.onRelease, this);

This link can help you:

https://developer.playcanvas.com/en/tutorials/ui-elements-buttons/

2 Likes

derickwelman is right.