Hello Rob,
I want to thank the help.
I want to ask one thing. In my code when you win a game in the end the box scores appears and also the button which you can share on facebook that score appears.
The first time you press the button to share on facebook , share the image with the result without problems but later when you want to share the result of another level it is locked and the app stops.
I do not know if it is because the screenshot is always kept with the same name or the problem is in my code .. please can you help me? this is the code:
local botonfb = display.newImage("images/fact.png")
botonfb:setReferencePoint ( display.CenterReferencePoint )
botonfb.x = imgRecords.x
botonfb.y = lbLifes.y + 90
pause:insert ( botonfb )
local function listener( event )
print( "event.name:" .. event.name ) --"fbconnect"
print( "isError: " .. tostring( event.isError ) )
print( "didComplete: " .. tostring( event.didComplete ) )
print( "event.type:" .. event.type ) --"session", "request", or "dialog"
if(event.phase == "release") then
facebook.login( appId, listener )
end
if ( "session" == event.type ) then
--options are "login", "loginFailed", "loginCancelled", or "logout"
if ( "login" == event.phase ) then
display.save( display.currentStage, { filename="screenshot.png", baseDir=system.TemporaryDirectory, captureOffscreenArea=true, backgroundColor={0,0,0,0} } )
local attachment = { message = "This is my score achieved in Dogchild! <3 Can you get better?", source = { baseDir=system.TemporaryDirectory, filename="screenshot.png", type="image" } }
facebook.request( "me/photos", "POST", attachment )
end
elseif ( "request" == event.type ) then
print("facebook request")
if ( not event.isError ) then
local response = json.decode( event.response )
end
elseif ( "dialog" == event.type ) then
print( "dialog", event.response )
end
end
local function loginFace( event )
facebook.login( appID, listener, { "publish_actions", "user_birthday" } )
end
botonfb:addEventListener( "touch" , loginFace )
As always thank you very much.
Tania.