Heya fellow Corona developers !
I have a serious problem !
I would like to grab a part of an image like a clamp and stretch it in the upper y direction wherever the image is positioned in the screen.
here is the code and my problem:
display.setStatusBar( display.HiddenStatusBar )
local \_W = display.contentWidth
local \_H = display.contentHeight
--set the graphic
local head = display.newImage("head.png")
head.x = \_W \*.5
head.y = \_H \*.5
--set the reference point to the bottom left to be able to stretch the upper part of the head
head:setReferencePoint(display.BottomLeftReferencePoint)
local function onTouch(event)
-------------
local t = event.target
local phase = event.phase
local stage = display.getCurrentStage()
--------------
if "began" == phase then
-- Make target the top-most object
local parent = t.parent
stage:setFocus(t)
t.isFocus = true
elseif t.isFocus then
----------------
if "moved" == phase then
-- I want the scale to follow my touch coordinate, but this line of code is not accurate since it doesn't track the touch efficiently
t.yScale = 1.5 \* (1-(event.y/display.contentHeight))
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( t, nil )
t.isFocus = false
end
end
return true
end
head:addEventListener("touch", onTouch)
I want the scale to follow my touch coordinate, but this line of code is not accurate since it doesn’t track the touch efficiently, so is anyone have a solution for this ?
I would like to move eventually the “head” object with the accelerometer and be able to scale it with my touch wherever the image is on the screen. I just need to know how to be able to scale a point in the image and that this point is scaling or “stretching” with my touch coordinates…
Thanks to anyone who can help me !
Ray [import]uid: 20617 topic_id: 11368 reply_id: 311368[/import]
[import]uid: 20617 topic_id: 11368 reply_id: 41282[/import]
[import]uid: 52491 topic_id: 11368 reply_id: 41343[/import]