hi i was post about gpgs doesnt show achievemnt… idk wuts wrong ith the code
it doesnt show my achievement…
anyone can help me fix it…?
[lua]-- --------------------------------------------------------------------------------------------
– Variables
local _W = display.contentWidth * 0.5;
local _H = display.contentHeight * 0.5;
local initCallback
local requestCallback
local globalData = require( “globalData” )
local json = require( “json” )
local gpgs = require( “plugin.gpgs” )
globalData.gpgs = nil
globalData.gameCenter = nil
local initCallback
local platform = system.getInfo( “platform” )
local env = system.getInfo( “environment” )
if ( platform == “android” and env ~= “simulator” ) then
globalData.gpgs = require( “plugin.gpgs” )
elseif ( platform == “ios” and env ~= “simulator” ) then
globalData.gameCenter = require( “gameNetwork” )
end
– Initialization Callback
– Google Play Games Services initialization/login listener
local function gpgsInitListener( event )
if not event.isError then
if ( event.name == “init” ) then – Initialization event
– Attempt to log in the user
globalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } )
elseif ( event.name == “login” ) then – Successful login event
print( json.prettify(event) )
end
end
end
function initCallback(event)
print(“initCallBack()”)
for k,v in pairs( event ) do
print( k,v )
end
if ( globalData.gpgs ) then
– Initialize Google Play Games Services
gpgs.init( “google”, gpgsInitCallback )
elseif ( globalData.gameCenter ) then
– Initialize Apple Game Center
globalData.gameCenter.init( “gamecenter”, gcInitListener )
end
end
– Request Callback
function requestCallback(event)
print(“requestCallback()”)
for k,v in pairs( event ) do
print( k,v )
end
if (event.type == “unlockAchievement”) then
– High score has been set
print(“event.type == unlockAchievement”)
end
end
– BUTTONS
local buttonListener
local button01
local button02
local button03
button01 = display.newImage(“start_btn.png”)
button01.x = _W
button01.y = _H - 100
button01.action = “connect”
button02 = display.newImage(“start_btn.png”)
button02.x = _W
button02.y = _H
button02.action = “unlock”
button03 = display.newImage(“start_btn.png”)
button03.x = _W
button03.y = _H + 100
button03.action = “show”
function buttonListener(event)
if event.phase == “ended” or event.phase == “cancelled” then
– Connecting to gameNetwork
if event.target.action == “connect” then
print(“button action == “connect””)
gpgs.init(“google”, initCallback)
– Unlocking achievement XXXXXXXXXXXXXXXXXX
elseif event.target.action == “unlock” then
gpgs.achievements.unlock (“unlockAchievement”,
{
achievement =
{
identifier = “CgkI8J_r9sMYEAIQAQ”
},
listener = requestCallback
}
)
– Showing achievements
elseif event.target.action == “show” then
print(“button action == “show””)
if ( globalData.gpgs ) then
globalData.gpgs.achievement.show (“CgkI8J_r9sMYEAIQAQ”)
end
end
end
end
– Adding touch events
button01:addEventListener(“touch”, buttonListener)
button02:addEventListener(“touch”, buttonListener)
button03:addEventListener(“touch”, buttonListener)[/lua]
idk why the code is not work
i cant show achievement…
i cant unlock achievement… achievement never show up… anyone help. ty
n when i build in android and open it by my phone… it show Rntime error com.naef.jnlua.LuaRuntimeException: This function requires from 0 to 1 arguments. Got 2.