It looks like you're new here. If you want to get involved, click one of these buttons!
local shape = Shape.new() shape:setFillStyle(Shape.SOLID, 0xff0000, 1) shape:beginPath() shape:moveTo(-50,-50) shape:lineTo(50, -50) shape:lineTo(50, 50) shape:lineTo(-50, 50) shape:lineTo(-50, -50) shape:endPath() shape:setPosition(150, 150) stage:addChild(shape) local rt = RenderTarget.new( shape:getWidth(), shape:getHeight() ) local x,y,w,h = shape:getBounds(stage) rt:draw( shape, -x,-y ) local bitmap = Bitmap.new(rt) bitmap:setPosition(-x/2,-y/2) bitmap:setColorTransform( 0,0,0,1 ) shape:addChild(bitmap) bitmap:setClip( 0,0,shape:getWidth(),shape:getHeight()/2 ) stage:addEventListener( Event.ENTER_FRAME, function() shape:setRotation(shape:getRotation()+1) end ) |
Comments
EDIT: Ah, your bitmap is a child of shape, so it should be rotated...
EDIT2: Ok, got it: rotation is applied before setClip(), so your clipped version of bitmap is always square!
Is there another way of doing this? See what I'd like to achieve below.
Likes: antix
Likes: totebo
Likes: antix, Apollo14