How to send an email through my cocos2d-x JS game?

  • efares
    Likes 0

    Problem Description

    Hi,

    I’m using Cocos2d-x v3.7 and I have a JS project.
    I am making an email button like this

            // Email Button
            var emailButton = new ccui.Button();
            emailButton.loadTextures("email_n.png", "email_s.png", "", ccui.Widget.PLIST_TEXTURE);
            emailButton.setTouchEnabled(true);
            emailButton.addTouchEventListener(this.onEmail, this);
            this.addChild(emailButton);

    And then when it is touched I want to do this:

    // Email selected
        onEmail: function (sender, type) {
            switch (type) {
            case ccui.Widget.TOUCH_BEGAN:
                break;
            case ccui.Widget.TOUCH_MOVED:
                break;
            case ccui.Widget.TOUCH_ENDED:
                cc.sys.href = 'mailto:email@gmail.com';
                // or windows.location.href = 'mailto:email@gmail.com';
                break;
            case ccui.Widget.TOUCH_CANCELLED:
                break;
            }
        }

    But neither of those 2 are working as expected. What am I missing or doing wrong? I’m sure there is more to it but I don’t know where to look or start.

    Thanks!

Login to reply