Sure:
[lua]
–local trans = require(“trans”)
display.setDefault( “v1Compatibility”, false )
display.setStatusBar( display.HiddenStatusBar )
local centerX,centerY = display.contentCenterX,display.contentCenterY
local rect = display.newRect(0,0,200,200)
rect.anchorX,rect.anchorY = 0.5,.5
rect.x,rect.y = centerX,centerY
rect.rPath = rect.path
rect:setFillColor(0,.5,1)
local corner = {}
corner.tlX = rect.path[‘x1’]
corner.trX = rect.path[‘x3’]
corner.blX = rect.path[‘x2’]
corner.brX = rect.path[‘x4’]
corner.tlY = rect.path[‘y1’]
corner.trY = rect.path[‘y3’]
corner.blY = rect.path[‘y2’]
corner.brY = rect.path[‘y4’]
local debug = display.newText(“Debug”, 20, 55, native.systemFont, 32)
debug:setTextColor(255,0,0)
debug.x,debug.y = centerX,50
local debugTxt = “”
local function transBack(obj,xx2,yy2)
transition.to(obj,{time=500,x2=xx2,y2=yy2,transition=easing.outBounce})
end
local function dragRect(event)
local t = event.target
local phase = event.phase
if phase == “began” then
display.getCurrentStage():setFocus( t, event.id )
t.isFocus = true
elseif t.isFocus then
if phase == “moved” then
t.x0 = event.x - t.x
t.y0 = event.y - t.y
t.path.x2 = corner.blX + t.x0 + t.width/2
t.path.y2 = corner.blY + t.y0 - t.height/2
--[[
t.path.x3 = corner.blX + t.x0 - t.width/2
t.path.y3 = corner.blY + t.y0 - t.height/2
]]–
elseif phase == “ended” or phase == “cancelled” then
--transBack(t.path,corner.blX,corner.blY)
--debug.text=t.path.y2
display.getCurrentStage():setFocus( t, nil )
t.isFocus = false
end
end
end
rect:addEventListener(“touch”,dragRect)
[/lua]
Click and Drag (it will use the bottom-left corner).
What you’ll notice aswell:
First time you start it, it will show a black screen! (it doesn’t show up any display.newRect - tested in other apps aswell)
After reloading (apple+r), it shows up and you can test it out.
I would really like this feature the most, but I’m a bit afraid with those bugs. And it seems we can’t make a build with that beta, right?