What part of the button isn’t working specifically? You click it and it does nothing, or ? [import]uid: 52491 topic_id: 30572 reply_id: 124730[/import]
The button works perfectly. I just not sure how to code the part that makes the button appear after the purchase is complete. I feel like I am missing something really simple. [import]uid: 34105 topic_id: 30572 reply_id: 124732[/import]
Easiest way would be to use something like Ego to save a value when the purchase is complete, then just check it when you reload the scene [import]uid: 52491 topic_id: 30572 reply_id: 124919[/import]
This worked for me too Peach.
Thank you very much! [import]uid: 34105 topic_id: 30572 reply_id: 124591[/import]
Glad to hear it, love it when I see a thread that can help more than one user - I feel twice as helpful [import]uid: 52491 topic_id: 30572 reply_id: 124657[/import]
Thank again peach.
I have a new question that for the life of me It’s just not clicking. So Some back ground My app will be a subscription app for 7 days. It seems like the transactions are working. With code like you have above. What I am trying to do is have the buy button removed once the subscription has been bought. Which your implementation from above seemed to work beautifully from initial tests. Next i am trying to create a button in the same spot after the purchase was successful that will use director class and take them to a new screen with a html file that points them to my server that I will update everyday. I just cant get that second button to work. This what i have so far but I have tried many other things implements at the beginning of that code without Success.
local touchfootballpickbtn = function( event )
if event.phase == "release" and footballpickbtn.isActive then
-- remove event listeners
-- main menu call
director:changeScene( "football" )
end
end
footballpickbtn = ui.newButton{
defaultSrc = "buy.png",
defaultX = 80,
defaultY = 36,
overSrc = "buy.png",
overX = 80,
overY = 36,
onEvent = touchfootballpickbtn,
id = "footballpickButton",
text = "",
font = "Helvetica",
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
footballpickbtn.x = 265; footballpickbtn.y = 121
footballpickbtn.isVisible = false
localGroup:insert( footballpickbtn )
timer.performWithDelay( 200, function() footballpickbtn.isVisible = true; end, 1 )
Thanks Again Peach. I really appreciate reading many of your posts [import]uid: 34105 topic_id: 30572 reply_id: 124701[/import]
What part of the button isn’t working specifically? You click it and it does nothing, or ? [import]uid: 52491 topic_id: 30572 reply_id: 124730[/import]
The button works perfectly. I just not sure how to code the part that makes the button appear after the purchase is complete. I feel like I am missing something really simple. [import]uid: 34105 topic_id: 30572 reply_id: 124732[/import]
Thanks Peach. I will check this out. [import]uid: 34105 topic_id: 30572 reply_id: 125114[/import]
Easiest way would be to use something like Ego to save a value when the purchase is complete, then just check it when you reload the scene [import]uid: 52491 topic_id: 30572 reply_id: 124919[/import]
Thanks Peach. I will check this out. [import]uid: 34105 topic_id: 30572 reply_id: 125114[/import]
OK Peach I researched EGO and went a little different route. This is what i changed. It looks like its purchasing but its not changing to frame 2.
local footballBtn = movieclip.newAnim({"buy.png","gobtn.png"}, 80, 36)
footballBtn.x = 265; footballBtn.y = 121
screenGroup:insert( footballBtn )
local onBuyfootballTouch = function( event )
if event.phase == "ended" and footballUnlocked ~= tonumber(loadedfootballUnlocked) then
audio.play( tapSound )
storyboard.gotoScene( "loader", "fade", 300 )
local buyfootball = function ( product )
print ("Congrats! Purchasing " ..product)
-- Purchase the item
if store.canMakePurchases then
store.purchase( {validProducts[1]} )
else
native.showAlert("Store purchases are not available, please try again later", { "OK" } )
end
end
-- Enter your product ID here
buyfootball("com.domain.app.football")
elseif event.phase == "ended" and footballUnlocked == tonumber(loadedfootballUnlocked) then
audio.play( tapSound )
storyboard.gotoScene( "football", "fade", 300 )
end
end
footballBtn:addEventListener( "touch", onBuyfootballTouch )
if footballUnlocked == tonumber(loadedfootballUnlocked) then
footballBtn:stopAtFrame(2)
end
Thanks Again [import]uid: 34105 topic_id: 30572 reply_id: 125580[/import]
Try using print statements to see where function is stopping and if values are being returned as required to move forward is my advice in these situations; then let me know results? [import]uid: 52491 topic_id: 30572 reply_id: 125654[/import]
Hello Peach,
I have put print statements into my code and it seems like all the transactions are occurring. I also checked my sand box file and the value is changing from 0 to 1. So my problem is with my button that must not be accessing that file and comparing it correctly. I have Narrowed the problem down to a few lines of Code.
Thanks peach for all your help. Your the best. [import]uid: 34105 topic_id: 30572 reply_id: 125734[/import]
OK Peach I researched EGO and went a little different route. This is what i changed. It looks like its purchasing but its not changing to frame 2.
local footballBtn = movieclip.newAnim({"buy.png","gobtn.png"}, 80, 36)
footballBtn.x = 265; footballBtn.y = 121
screenGroup:insert( footballBtn )
local onBuyfootballTouch = function( event )
if event.phase == "ended" and footballUnlocked ~= tonumber(loadedfootballUnlocked) then
audio.play( tapSound )
storyboard.gotoScene( "loader", "fade", 300 )
local buyfootball = function ( product )
print ("Congrats! Purchasing " ..product)
-- Purchase the item
if store.canMakePurchases then
store.purchase( {validProducts[1]} )
else
native.showAlert("Store purchases are not available, please try again later", { "OK" } )
end
end
-- Enter your product ID here
buyfootball("com.domain.app.football")
elseif event.phase == "ended" and footballUnlocked == tonumber(loadedfootballUnlocked) then
audio.play( tapSound )
storyboard.gotoScene( "football", "fade", 300 )
end
end
footballBtn:addEventListener( "touch", onBuyfootballTouch )
if footballUnlocked == tonumber(loadedfootballUnlocked) then
footballBtn:stopAtFrame(2)
end
Thanks Again [import]uid: 34105 topic_id: 30572 reply_id: 125580[/import]
Try using print statements to see where function is stopping and if values are being returned as required to move forward is my advice in these situations; then let me know results? [import]uid: 52491 topic_id: 30572 reply_id: 125654[/import]
Hello Peach,
I have put print statements into my code and it seems like all the transactions are occurring. I also checked my sand box file and the value is changing from 0 to 1. So my problem is with my button that must not be accessing that file and comparing it correctly. I have Narrowed the problem down to a few lines of Code.
Thanks peach for all your help. Your the best. [import]uid: 34105 topic_id: 30572 reply_id: 125734[/import]