点按不在触摸设备上运行的事件

时间:2017-02-07 09:57:33

标签: javascript mobile click touch prototype

我有一个游戏,随机门票从画布顶部落下。目的是在门票落下时点击门票。一切都在桌面上工作,但点击事件不适用于移动设备。下面是负责click事件的代码片段。任何人都可以告诉我如何重写这个以便在触摸设备上触发点击/触摸事件吗?

/**
 * Global game events
 */
var GameEvents = (function () {
    function GameEvents() {
    }
    GameEvents.ON_PRESS_START = "ON_PRESS_START";
    GameEvents.ON_TIME_UP = "ON_TIME_UP";
    GameEvents.ON_TICKET_CLICKED = "ON_TICKET_CLICKED";
    GameEvents.ON_SUBMIT_SCORE = "ON_SUBMIT";
    return GameEvents;
}());


    /**
     * Start!
     */
    SceneMain.prototype.onPressStart = function () {
        // start the particles
        this._particles.start();
        this._particles.setInteraction(this.onTicketClicked.bind(this));
        this._score = 0;
        this._$scoreValue.text(0);
        // start the timer
        this._secondsRemaining = this._layout.getLayoutParams().time_limit;
        this._$timeValue.text(this._layout.getLayoutParams().time_limit);
        this._timer = new DelayCall(this.onTick.bind(this), 1000, DO.Core.Time.juggler, this._layout.getLayoutParams().time_limit, this.onTimeUp.bind(this));
        this._timer.start();
    };



/**
                     * Ticket has been clicked
                     */
                    SceneMain.prototype.onTicketClicked = function (e) {
                        // score anim
                        // this._$scoreValue.removeClass("score_throb");
                        // remove the ticket
                        var ticket = e.target;
                        ticket.kill();
                        // increase score
                        this._score++;
                        this._$scoreValue.text(this._score);
                        // score anim
                        //this._$scoreValue.addClass("score_throb");
                    };

0 个答案:

没有答案