It looks like you're new here. If you want to get involved, click one of these buttons!
-- load texture, create bitmap from it and set as background local background = Bitmap.new(Texture.new("sky_world.png")) stage:addChild(background) -- bird_black_01 = 100 w x 44 h local bird1 = Bitmap.new(Texture.new("bird_black_01.png")) local bird2 = Bitmap.new(Texture.new("bird_black_01.png")) local bird3 = Bitmap.new(Texture.new("bird_black_01.png")) local bird4 = Bitmap.new(Texture.new("bird_black_01.png")) -- draw bird 1 bird1:setPosition(0,0) -- draw bird 2, clip to half width and half height bird2:setPosition(150,0) bird2:setClip(0,0,50,22) -- draw bird 3, scale to 50% bird3:setPosition(300,0) bird3:setScale(0.5) -- now bird 4, scale to 50% and then apply the same clip -- as the image is now half the size the clip should have zero effect as the image is now 50x22, but it has the exact same affect as the first clip. bird4:setPosition(0,150) bird4:setScale(0.5) bird4:setClip(0,0,50,22) -- add birds to the stage stage:addChild(bird1) stage:addChild(bird2) stage:addChild(bird3) stage:addChild(bird4) |
Comments
I could understand if there was a flag to say local or scaled but to have no option of scaled just seems odd.
I tried using a container sprite and no matter which way I tried it never gave the correct result.
This did, but is woefully inefficient
If it is possible without doing this extra maths with a container would be great to see how as I just can't make it work (Even though in theory it should)
I would have done the way below (though it needs one more Sprite, right, but Sprites are cheap)
Likes: ChrisF
Your thoughts on applying it to untransformed coordinates make perfect sense, just not for all scenarios.
For previous projects it would be fine. For this I do not know if I need to clip it until after I have scaled it, (I am being lazy and just grabbing a scale from a table based upon distance from camera) , so it is only once I have scaled the object do I know it's new size (just grabbing using getWidth() & getHeight) and I check and if it needs to be clipped or not (if that makes).
Anyway thanks for your help the workaround should be fine.