Hi Rob,
I tried to solve your (interesting) problem.
The result it’s certainly rough, and really I don’t know if it can come you in handy (keep in mind that I have started to program only 4 months ago).
Anyway, here is the code. Copy and paste in your editor.
–> START
display.setStatusBar(display.HiddenStatusBar);
local p = require “physics”;
p.start();
p.setDrawMode(“hybrid”);
local ground = display.newRect(0, 479, 320, 1 )
p.addBody(ground, “static”,{})
ground:setFillColor(200,200,200)
local message1 = display.newText(
“Hi, I’m the red crate.”,
0, 0, 20
)
message1:setReferencePoint(display.CenterReferencePoint)
message1.x = 160; message1.y = 200
local message2 = display.newText(
“I want to show you something. Click on me please.”,
0, 0, 20
)
message2:setReferencePoint(display.CenterReferencePoint)
message2.x = 160; message2.y = 220
local crate1 = display.newRect(0,0,40,40)
crate1.x=140; crate1.y=459
crate1:setFillColor(0,0,255)
p.addBody(crate1,“dynamic”,{})
local crate2 = display.newRect(0,0,40,40)
crate2.x=180; crate2.y=459
crate2:setFillColor(255,0,0)
p.addBody(crate2,“dynamic”,{})
local plus = 0
local function growing(e)
if crate2.height <= 100 then do
message1.text = “”
message2.text = “UUUUAAAAAARRRRRRGHHHHH!!!”
crate2:removeSelf()
crate2 = display.newRect(0,0,(40 + plus),(40 + plus))
crate2.x=180; crate2.y= (459 - (plus/2))
crate2:setFillColor(0,255,0)
p.addBody(crate2,“dynamic”,{})
plus = plus + 2
end
else
Runtime:removeEventListener(“enterFrame”, growing)
end
end
local function callGrowing(e)
if e.phase == “ended” then
Runtime:addEventListener(“enterFrame”, growing)
end
end
crate2:addEventListener(“touch”, callGrowing)
–> END
I’ll try some other solution. That’s it for now. Bye!
[import]uid: 70416 topic_id: 12697 reply_id: 46797[/import]