Any ideas on how to create a scratching effect (that reveals what is behind)? I saw a sample in the Code Exchange but, unfortunately it is not available anymore…
Ideas are appreciated! [import]uid: 4883 topic_id: 34719 reply_id: 334719[/import]
Any ideas on how to create a scratching effect (that reveals what is behind)? I saw a sample in the Code Exchange but, unfortunately it is not available anymore…
Ideas are appreciated! [import]uid: 4883 topic_id: 34719 reply_id: 334719[/import]
Here is some code I think I found on code exchange or somewhere on the corona site:
(you will have to substitute your own images in place of the ones listed in this code)
you don’t really need the ‘scratchTicket.png’ it is just there for background
the test.png is just a grey circular like image, like a burst of grey 60x60 in size
– Sample code is MIT licensed, see http://developer.anscamobile.com/code/license
– Copyright © 2010 ANSCA Inc. All Rights Reserved.
display.setStatusBar( display.HiddenStatusBar )
local halfW = display.contentCenterX
local halfH = display.contentCenterY
local reward = display.newImage(“winner1.png”, true)
reward.x = 380
reward.y = 800
–paint in the area to be erased…
function onCircleTouch(event)
local c = event.target
display.remove©
–print(“here”)
end
local numAcross = 26
local numDown = 13
local offset = 20
for i=1,numDown do
for x=1, numAcross do
–Originally started throwing circles all over the place, performacne was bad on the devices
–local theCircle = display.newCircle(100,100,30)
local theCircle = display.newImage(“test.png”,true)
theCircle.x = 118 + (x * offset)
theCircle.y = 676 + (i * offset)
–theCircle:setFillColor(161,161,157, 150) --Only need this line if you are using the circles, try it out
theCircle:addEventListener(“touch”, onCircleTouch)
end
end
– Background image
local bkg = display.newImage( “ScratchTicket.png”, true )
bkg.x = halfW
bkg.y = halfH
[import]uid: 148857 topic_id: 34719 reply_id: 137975[/import]
thanks a lot! [import]uid: 4883 topic_id: 34719 reply_id: 138152[/import]
Here is some code I think I found on code exchange or somewhere on the corona site:
(you will have to substitute your own images in place of the ones listed in this code)
you don’t really need the ‘scratchTicket.png’ it is just there for background
the test.png is just a grey circular like image, like a burst of grey 60x60 in size
– Sample code is MIT licensed, see http://developer.anscamobile.com/code/license
– Copyright © 2010 ANSCA Inc. All Rights Reserved.
display.setStatusBar( display.HiddenStatusBar )
local halfW = display.contentCenterX
local halfH = display.contentCenterY
local reward = display.newImage(“winner1.png”, true)
reward.x = 380
reward.y = 800
–paint in the area to be erased…
function onCircleTouch(event)
local c = event.target
display.remove©
–print(“here”)
end
local numAcross = 26
local numDown = 13
local offset = 20
for i=1,numDown do
for x=1, numAcross do
–Originally started throwing circles all over the place, performacne was bad on the devices
–local theCircle = display.newCircle(100,100,30)
local theCircle = display.newImage(“test.png”,true)
theCircle.x = 118 + (x * offset)
theCircle.y = 676 + (i * offset)
–theCircle:setFillColor(161,161,157, 150) --Only need this line if you are using the circles, try it out
theCircle:addEventListener(“touch”, onCircleTouch)
end
end
– Background image
local bkg = display.newImage( “ScratchTicket.png”, true )
bkg.x = halfW
bkg.y = halfH
[import]uid: 148857 topic_id: 34719 reply_id: 137975[/import]
thanks a lot! [import]uid: 4883 topic_id: 34719 reply_id: 138152[/import]