ok here’s a (very rough) magnifying glass using capture screen, but it’s late and i can’t work out the maths to scale the movement. I didnt understand the need for the web popup in your example though
a couple of things to note
* the screen capture is scaled, then masked
* scaling the capture seems to scale the mask (bug?)
* the screen capture would also actually need to move based on the scale, otherwise you end up with the lens showing the wrong thing underneath. i’ve not implemented this. basically since i’ve magnified from the centre, as you move towards the edge the magnified bit is further away.
* it doesn’t scale correctly when viewing as iPhone4 etc… need to modify some of the calculations config etc i think
if someone could post any fixes that would be great
the end target would be to have it re-capture the display anytime the user clicks on the screen/magnifying glass etc. this would mean that the main original screen would need to be static (not updating) until you let go again. essentially you’re just viewing a screen capture.
also you’d probably want to overlay the graphic of a magnifying glass at the same position as the mask. it probably gets more complicated if you try to start putting them in display groups together, as the mask isnt a separate image as such , it’s a part of the scaled image here
regards
J
[lua]display.setStatusBar( display.HiddenStatusBar )
local halfW = display.contentCenterX
local halfH = display.contentCenterY
local W = display.contentWidth
local H = display.contentHeight
local canvas = display.newGroup()
local rnd = math.random
for i=1, 200, 1 do
local line = display.newLine(rnd()*W, rnd()*H, rnd()*W, rnd()*H)
line:setColor(rnd()*255,rnd()*255,rnd()*255)
canvas:insert(line)
local box = display.newRect(rnd()*W, rnd()*H, 2+rnd()*50, 2+rnd()*50)
box:setFillColor(rnd()*255,rnd()*255,rnd()*255)
canvas:insert(box)
end
local canvascopy = display.captureScreen()
local SCALE_RATIO = 2
canvascopy.xScale=SCALE_RATIO
canvascopy.yScale=SCALE_RATIO
local mask = graphics.newMask( “circlemask.png” )
canvascopy:setMask(mask)
canvascopy.maskScaleX=1/SCALE_RATIO
canvascopy.maskScaleY=1/SCALE_RATIO
function onTouch( event )
print(“touch”)
local t = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
– Spurious events can be sent to the target, e.g. the user presses
– elsewhere on the screen and then moves the finger over the target.
– To prevent this, we add this flag. Only when it’s true will “move”
– events be sent to the target.
t.isFocus = true
– Store initial position
t.x0 = (event.x - t.maskX*SCALE_RATIO)
t.y0 = (event.y - t.maskY*SCALE_RATIO)
elseif t.isFocus then
if “moved” == phase then
– Make object move (we subtract t.x0,t.y0 so that moves are
– relative to initial grab point, rather than object “snapping”).
t.maskX = (event.x - t.x0)/SCALE_RATIO
t.maskY = (event.y - t.y0)/SCALE_RATIO
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
return true
end
canvascopy:addEventListener( “touch”, onTouch )[/lua] [import]uid: 6645 topic_id: 3647 reply_id: 21106[/import]