ok! Sent you a file! my nick i barmyman [import]uid: 169507 topic_id: 32361 reply_id: 139157[/import]
Unfortunatlly bad luck! contentToLocal doesnt work!
i made little demo, and you will see my problem! demo is based on drawing with undo
try to get ball higher with line and you will see
Please! Help me! You will be my hero!) [import]uid: 169507 topic_id: 32361 reply_id: 139006[/import]
UPDATE! okay! i made it!
But there is a problem - i can properly draw line, it contents to local, but physics body doesn’t…
Here is a line code which i use with fix:
[code]
local function drawLine(e)
if(e.phase == “began”) then
if(line) then
lineGroup:remove(1)
line = nil
end
prevX = e.x
prevY = e.y
isDrawing = true
lineGroup.x, lineGroup.y = gameGroup:contentToLocal(e.x - prevX, e.y - prevY)
print(“1”)
elseif(e.phase == “moved”) then
local distance = distanceBetween(prevX, prevY, e.x, e.y)
local distance_min = distanceBetween(prevX, prevY, e.x, e.y)
if(isDrawing and distance_min > 10 and distance < 200) then
local distance1 = distanceBetween(prevX, prevY, e.x, e.y)
if(line) then lineGroup:remove(1) end
line = display.newLine(prevX, prevY, e.x, e.y)
line.myName = “line”
line:setColor(255, 255, 0)
line.width = 6
local dist_x = e.x - prevX
local dist_y = e.y - prevY
line_shape = {0, 0, dist_x, dist_y, 0, 0}
physics.addBody(line, “static”, { density = 1, friction = 0.51, bounce = 1.34, shape = line_shape } )
lineGroup:insert(line)
transition.to(game_round, {time=10, alpha=0, alpha=1})
game_round.x = e.x
game_round.y = e.y
lineGroup:insert(game_round)
end
elseif(e.phase == “ended”) then
isDrawing = false
transition.to(game_round, {time=80, alpha=1, alpha=0})
line_count:increment(“line_count”, 1)
line_count:save()
print(line_count:get(“line_count”))
end
end
Runtime:addEventListener(“touch”,drawLine)
[/code] [import]uid: 169507 topic_id: 32361 reply_id: 139043[/import]
Generally, if you move display groups and the physics bodies suddenly stop working properly, its because you’re not moving a display group which contains ALL of the physics bodies. [import]uid: 8271 topic_id: 32361 reply_id: 139165[/import]
Finally figured it all out! horacebury, thank you for support! [import]uid: 169507 topic_id: 32361 reply_id: 139210[/import]
[import]uid: 8271 topic_id: 32361 reply_id: 139219[/import]
Could you post the relevant portion of your code? I’m very, very certain that contentToLocal does work. You need to be aware of what object you are using it on. [import]uid: 8271 topic_id: 32361 reply_id: 139013[/import]
Can somebody help me, please?(
I think that it is just a one-line issue, i need this physics body to move.
By the way: corona with it’s “hybrid” mode shows that when i draw a line, physics body is in the right place! but actually it is not [import]uid: 169507 topic_id: 32361 reply_id: 139142[/import]
The code you’ve posted is incomplete and requires a lot of work to get it to a point where the logical problem can be resolved. Can you post the entire code please? If that requires you to post your whole game/app listing, then you need to reduce the problem to a sample file which can run on its own without other problems. [import]uid: 8271 topic_id: 32361 reply_id: 139146[/import]
could you post your e-mail? just don’t want to share this demo as it is copyright already ) [import]uid: 169507 topic_id: 32361 reply_id: 139149[/import]
I don’t mean the demo, I mean a very, very reduced set of functionality which provides only the problem you are seeing. [import]uid: 8271 topic_id: 32361 reply_id: 139151[/import]
I can’t download that file. Contact me at horace dot bury at google’s mail dot com [import]uid: 8271 topic_id: 32361 reply_id: 139155[/import]
Here is a little show up of the problem!
Really appreciate your help, man! Thank you! [import]uid: 169507 topic_id: 32361 reply_id: 139153[/import]
ok! Sent you a file! my nick i barmyman [import]uid: 169507 topic_id: 32361 reply_id: 139157[/import]
Unfortunatlly bad luck! contentToLocal doesnt work!
i made little demo, and you will see my problem! demo is based on drawing with undo
try to get ball higher with line and you will see
Please! Help me! You will be my hero!) [import]uid: 169507 topic_id: 32361 reply_id: 139006[/import]
UPDATE! okay! i made it!
But there is a problem - i can properly draw line, it contents to local, but physics body doesn’t…
Here is a line code which i use with fix:
[code]
local function drawLine(e)
if(e.phase == “began”) then
if(line) then
lineGroup:remove(1)
line = nil
end
prevX = e.x
prevY = e.y
isDrawing = true
lineGroup.x, lineGroup.y = gameGroup:contentToLocal(e.x - prevX, e.y - prevY)
print(“1”)
elseif(e.phase == “moved”) then
local distance = distanceBetween(prevX, prevY, e.x, e.y)
local distance_min = distanceBetween(prevX, prevY, e.x, e.y)
if(isDrawing and distance_min > 10 and distance < 200) then
local distance1 = distanceBetween(prevX, prevY, e.x, e.y)
if(line) then lineGroup:remove(1) end
line = display.newLine(prevX, prevY, e.x, e.y)
line.myName = “line”
line:setColor(255, 255, 0)
line.width = 6
local dist_x = e.x - prevX
local dist_y = e.y - prevY
line_shape = {0, 0, dist_x, dist_y, 0, 0}
physics.addBody(line, “static”, { density = 1, friction = 0.51, bounce = 1.34, shape = line_shape } )
lineGroup:insert(line)
transition.to(game_round, {time=10, alpha=0, alpha=1})
game_round.x = e.x
game_round.y = e.y
lineGroup:insert(game_round)
end
elseif(e.phase == “ended”) then
isDrawing = false
transition.to(game_round, {time=80, alpha=1, alpha=0})
line_count:increment(“line_count”, 1)
line_count:save()
print(line_count:get(“line_count”))
end
end
Runtime:addEventListener(“touch”,drawLine)
[/code] [import]uid: 169507 topic_id: 32361 reply_id: 139043[/import]
Generally, if you move display groups and the physics bodies suddenly stop working properly, its because you’re not moving a display group which contains ALL of the physics bodies. [import]uid: 8271 topic_id: 32361 reply_id: 139165[/import]
Finally figured it all out! horacebury, thank you for support! [import]uid: 169507 topic_id: 32361 reply_id: 139210[/import]
[import]uid: 8271 topic_id: 32361 reply_id: 139219[/import]