我该如何在卡罗纳中调用发送电子邮件的函数?

以下是我正在编写的简单游戏的代码部分,我正在尝试发送一封电子邮件,其中包含用户在菜单屏幕上花费的时间。我不确定在哪里调用选项函数。

-- 发送邮件到我的邮箱
local options =
{
    to = "richard@gmail.com",
    subject = "在菜单屏幕上花费的时间",
    body = "这是我花费的时间,查看菜单" .. (os.time() - startTime),
}
native.showPopup("mail", options)

-- 初始化所有游戏逻辑的函数
function Main()
    splash:removeSelf()
    splash = nil

    playGame = display.newImage("Play Button.png")
    tutorial = display.newImage("Tutorial Button.png")
    credits = display.newImage("Credits Button.png")

    playGame.x = display.contentWidth / 2
    playGame.y = display.contentWidth - 187
    tutorial.x = display.contentWidth / 2
    tutorial.y = display.contentWidth - 130
    credits.x = display.contentWidth / 2
    credits.y = display.contentWidth - 73

    startButtonListeners('add')
end

-- 在菜单屏幕上添加按钮监听器
function startButtonListeners(action)
    if (action == 'add') then
        playGame:addEventListener ('tap', showGameView)
        credits: addEventListener ('tap', showCredits)
        tutorial: addEventListener ("tap", showTutorial)
    else
        playGame:removeEventListener ('tap', showGameView)
        print("在菜单屏幕上花费的时间:", (os.time() - startTime))
        credits: removeEventListener ('tap', showCredits)
        tutorial: removeEventListener ('tap', showTutorial)
    end
end
点赞
用户1979583
用户1979583

我无法完全理解您的需要。我认为,当您离开屏幕或游戏结束时,您需要发送电子邮件到特定的地址。因此,当您的游戏结束或通过触发按钮离开屏幕时,您可以调用一个带有 options 参数的函数。就像下面这样:

local function sendMail()
   local options =
   {
     to = "richard@gmail.com",
     subject = "Time spent at the menu screen",
     body = "This is the time I spent to look at the menu"..(os.time() - startTime),
    }
    native.showPopup("mail", options)
end

...
...
...
sendMail()  -- 当游戏结束/离开场景前调用此函数

欲知更多信息,请参考此链接: 如何使用Corona SDK邮寄屏幕截图图像

保持编码............. :)

2014-02-27 04:35:02