Hi
This is a real show stopper for me. Consider the following… I have to Rects, same size, same position on the screen. Now, what I want to simulate is that one of the rects is a bucket and the other rect is water inside the bucket. Moving the “bucket” to the left side (in the onTouch event) causes the bucket to tip over and the water-rect should reduce in “height”. To achieve this, I have set the SetReferencePoint to BottomLeft, so when the bucket tips over, the rect sits on the bottom left side (tipping to the left). No problems so far… But, when the height of the other rect (the water) is reduced, it seems like the height is calculated from the center of the rect (assuming it its reference point is Center?). So the “water” rect moves gradually to the center when the height is reduced (1px every frame)
I have now idea how to get around this. I have tried with transitions and so on but no luck
Sample code
-- Simulate bucket
bucket = display.newRect(screenWidth \*0.5, 700, 100, 100)
bucket:setReferencePoint(display.BottomLeftReferencePoint)
bucket.x = screenWidth \*0.5
bucket.y = 700
bucket:setFillColor(0, 255, 0, 100)
bucket:addEventListener( "touch", onTouch )
--Simualate water
water = display.newRect(screenWidth \*0.5, 700, 100, 100)
water:setReferencePoint(display.BottomLeftReferencePoint)
water:setFillColor(0, 0, 255)
water.x = screenWidth \*0.5
water.y = 700
local function main( event )
if(math.abs(bucket.rotation) == 45) then
if(water.height \> 2) then
local newHeight = water.height-1
water.height = newHeight --NOT CALCULATED FROM REFERENCE POINT ??
end
end
end
Runtime:addEventListener( "enterFrame", main )
[import]uid: 36300 topic_id: 7132 reply_id: 307132[/import]