Hi I use it:
system.openURL( "http://www.google.com" )
here:
if clickedButton == g\_rateButton then
but it don’t work.Who can help me? Please
Hi I use it:
system.openURL( "http://www.google.com" )
here:
if clickedButton == g\_rateButton then
but it don’t work.Who can help me? Please
You will need to post more code. Where do you setup your button? What does your entire button handler look like?
Rob
g\_rateButton = nil g\_playButton = nil g\_rankButton = nil local clickedButton = nil local function checkMenuButton(button, name, point) cclog("checkMenuButton : "..name) local buttonSize = getSpriteSize(name) local buttonX = button:getPositionX() local buttonY = button:getPositionY() if math.abs(point.x - buttonX) \< buttonSize.width / 2 and math.abs(point.y - buttonY) \< buttonSize.height / 2 then clickedButton = button return true end return false end -- listener local touchBeginPoint = nil function onCommonMenuLayerTouchBegan(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchBegan: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = {x = location.x, y = location.y} if g\_rateButton ~= nil then checkMenuButton(g\_rateButton, "button\_rate", touchBeginPoint) end if g\_playButton ~= nil then checkMenuButton(g\_playButton, "button\_play", touchBeginPoint) end if g\_rankButton ~= nil then checkMenuButton(g\_rankButton, "button\_score", touchBeginPoint) end if g\_plusButton ~= nil then checkMenuButton(g\_plusButton, "plus", touchBeginPoint) end if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() - 3)) end -- CCTOUCHBEGAN event must return true return true end function onCommonMenuLayerTouchEnded(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchEnded: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = nil if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() + 3)) if clickedButton == g\_rateButton then system.openURL("http://google.com") end elseif clickedButton == g\_playButton then local gameScene = nil if g\_initFlag == nil then gameScene = require("scripts.GameScene") else gameScene = createGameScene() end local trans = cc.TransitionFade:create(0.5, gameScene, cc.c3b(0,0,0)) cc.Director:getInstance():replaceScene(trans) cc.SimpleAudioEngine:getInstance():playEffect(uiPath) elseif clickedButton == g\_rankButton then showAds() end clickedButton = nil end end
I don’t know what this cc.* library is or what it does. I can’t really help too much. I’m guessing that **if** your checkMenuButton() function actually gets those parameters (most implementations of Corona touch handlers don’t pass in extra parameters beyond their event table), that you would want to do something like:
if name == "button\_rate" then system.openURL("http://www.google.com") elseif name == "button\_play" then -- do whatever you want that button to do. elseif name == "button\_somethingelse" then -- do more things end
However you should look at the Corona SDK native.showPopup() API call. We have functions that let you bring up the store’s ratings and reviews page. See: http://docs.coronalabs.com/api/library/native/showPopup.html#appstore
Rob
You will need to post more code. Where do you setup your button? What does your entire button handler look like?
Rob
g\_rateButton = nil g\_playButton = nil g\_rankButton = nil local clickedButton = nil local function checkMenuButton(button, name, point) cclog("checkMenuButton : "..name) local buttonSize = getSpriteSize(name) local buttonX = button:getPositionX() local buttonY = button:getPositionY() if math.abs(point.x - buttonX) \< buttonSize.width / 2 and math.abs(point.y - buttonY) \< buttonSize.height / 2 then clickedButton = button return true end return false end -- listener local touchBeginPoint = nil function onCommonMenuLayerTouchBegan(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchBegan: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = {x = location.x, y = location.y} if g\_rateButton ~= nil then checkMenuButton(g\_rateButton, "button\_rate", touchBeginPoint) end if g\_playButton ~= nil then checkMenuButton(g\_playButton, "button\_play", touchBeginPoint) end if g\_rankButton ~= nil then checkMenuButton(g\_rankButton, "button\_score", touchBeginPoint) end if g\_plusButton ~= nil then checkMenuButton(g\_plusButton, "plus", touchBeginPoint) end if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() - 3)) end -- CCTOUCHBEGAN event must return true return true end function onCommonMenuLayerTouchEnded(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchEnded: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = nil if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() + 3)) if clickedButton == g\_rateButton then system.openURL("http://google.com") end elseif clickedButton == g\_playButton then local gameScene = nil if g\_initFlag == nil then gameScene = require("scripts.GameScene") else gameScene = createGameScene() end local trans = cc.TransitionFade:create(0.5, gameScene, cc.c3b(0,0,0)) cc.Director:getInstance():replaceScene(trans) cc.SimpleAudioEngine:getInstance():playEffect(uiPath) elseif clickedButton == g\_rankButton then showAds() end clickedButton = nil end end
I don’t know what this cc.* library is or what it does. I can’t really help too much. I’m guessing that **if** your checkMenuButton() function actually gets those parameters (most implementations of Corona touch handlers don’t pass in extra parameters beyond their event table), that you would want to do something like:
if name == "button\_rate" then system.openURL("http://www.google.com") elseif name == "button\_play" then -- do whatever you want that button to do. elseif name == "button\_somethingelse" then -- do more things end
However you should look at the Corona SDK native.showPopup() API call. We have functions that let you bring up the store’s ratings and reviews page. See: http://docs.coronalabs.com/api/library/native/showPopup.html#appstore
Rob