Touch-Drag to Resize circle?

Hi All,
I’m having trouble integrating this “grow controller” I wish to have a dot that you can pull outwards from the middle to resize, release then resize from it’s current radius to a larger or smaller size.
I picture is worth a million words so here goes:

The tricky part is that I don’t want it to reset itself to small on the second touch, if that makes sense…

would you recommend a resizable button or to just code it in a touch event handler?

Any pointers to get me started would be greatly appreciated!
Thanks

Alex [import]uid: 66618 topic_id: 19804 reply_id: 319804[/import]

i could only come up with this, hope it helps
[lua]local ball = display.newCircle(0,0,10)
ball.x = 150
ball.y = 150

local var = 0

local i = 0
local lastscalex = 0
local lastscaley = 0

local function drag_resize(event)
if event.phase == “began” then

display.getCurrentStage():setFocus(event.target)

i = event.x
elseif event.phase == “moved” then
if event.x > i then
var = i + event.x

if var*0.01 > ball.xScale then
ball.xScale = var*0.01
end
if var*0.01 > ball.yScale then
ball.yScale = var*0.01
end

print(var)
end
elseif event.phase == “ended” or event.phase == “cancelled” then
lastscalex = ball.xScale
lastscaley = ball.yScale

display.getCurrentStage():setFocus(nil)

end
end
ball:addEventListener(“touch”, drag_resize)[/lua] [import]uid: 16142 topic_id: 19804 reply_id: 76791[/import]

Thanks DarkConsoles!

That’s very helpful and exactly what I envisioned for the initial growing. Now to figure out how to make it smaller again.

This will keep me busy over new years :slight_smile:

Happy new year to all!
Alex [import]uid: 66618 topic_id: 19804 reply_id: 76792[/import]

be sure to post the solution here if you find it out

happy new year! [import]uid: 16142 topic_id: 19804 reply_id: 76798[/import]

Try this maybe…I don’t know what your after but maybe
play with it or both to make things your way…:slight_smile:

[code]–
– This may work for ya or you can play with it to get maybe what ya want…:slight_smile:
– it is really simple to understand and do
– Have fun! Sharp1959 (Larry)

local cir_rd = 30
local circle_1 = nil

circle_1 = display.newCircle(200, 200, cir_rd )

function letsResizeNow(event)

–use event.x on screen to tell us how to resize RADIUS (use cir_rd * 2 to get 60 for diameter)
cir_rd = ((event.x - circle_1.x) + 60)

–remove old circle
circle_1:removeSelf()

–redraw new(SIZED) circle same x and y different radius
circle_1 = display.newCircle(200, 200, cir_rd)

–Just because we what to change the color and see resize works
circle_1:setFillColor(math.random (255), math.random (255),math.random (255))

end

Runtime:addEventListener( “touch”, letsResizeNow )[code]

Have FUN!
Larry
[import]uid: 107633 topic_id: 19804 reply_id: 76799[/import]

@sharp1959, wow, its simple and awesome) [import]uid: 16142 topic_id: 19804 reply_id: 76800[/import]

Just remember it is a Runtime Event
Runtime:addEventListener( “touch”, letsResizeNow )

May have to play a litte to get circle touch event to work depending on what your looking for
[import]uid: 107633 topic_id: 19804 reply_id: 76801[/import]

Fantastic!

Thanks so much for your help!!!

Happy new year to all :slight_smile: [import]uid: 66618 topic_id: 19804 reply_id: 76802[/import]

Happy Newyear to you also, and BE safe!
Have Fun! :slight_smile:

Larry
[import]uid: 107633 topic_id: 19804 reply_id: 76804[/import]

Yes, not too much Corona before driving :wink: [import]uid: 66618 topic_id: 19804 reply_id: 76805[/import]