2014-02-26 2 views
3

아래는 내가 쓰고있는 간단한 게임 코드의 일부입니다. 사용자가 메뉴 화면에서 보낸 시간을 포함하는 이메일을 보내려고합니다. 옵션 기능을 호출 할 위치가 확실하지 않습니다.이 코드에서 코로나로 이메일을 보내는 기능을 어떻게 호출합니까?

--Send a email to my own address 
local options = 
{ 
to = "[email protected]", 
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) 

--Function that initializes all game logic 
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 

--Adds listeners to the button in menu screen 
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("Time spent at menu screen: ", (os.time() - startTime)) 
     credits: removeEventListener ('tap', showCredits) 
     tutorial: removeEventListener ('tap', showTutorial) 
      end 
end 

답변

2

나는 당신의 필요를 완전히 이해할 수 없었다. 내 생각에, 화면을 떠났거나 게임이 끝나면 특정 주소로 전자 메일을 보내야합니다. 따라서 게임이 끝나거나 버튼을 트리거하여 화면을 떠날 때 options 함수를 호출 할 수 있습니다. 다만 아래와 같이 자세한 정보에 대한

local function sendMail() 
    local options = 
    { 
    to = "[email protected]", 
    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() -- Call this when the game is over/before you leave the scene 

도이 링크를 참조하십시오 How to mail a screen captured image using corona SDK

............. :

+0

감사 코딩 유지,이 중량입니다 내가 찾고 있어요. Btw, 코드가 컴퓨터에서 작동하는지 테스트하는 방법이 있습니까? 코드를 실행했지만 아무 일도 일어나지 않았으며 이메일을 찾을 수 없습니다. – user3305142

+1

코로나 기본 메일 팝업은 코로나 시뮬레이터에서 작동하지 않습니다. Xcode 시뮬레이터 용 또는 테스트 용 장치 중 하나를 빌드해야합니다. –

관련 문제