This has been bugging me for a while, but not enough to write a post about it. Until now!
What's the correct way of drawing a moved sprite to a RenderTarget?
This, predictably, causes clipping:
local source = Bitmap.new(Texture.new("calm.png"))
source:setPosition(100,100)
local rt = RenderTarget.new(source:getWidth(), source:getHeight())
local bmp = Bitmap.new(rt)
rt:draw(source)
stage:addChild(bmp) |
This works, but feels cumbersome:
local source = Bitmap.new(Texture.new("calm.png"))
source:setPosition(100,100)
local rt = RenderTarget.new(source:getWidth(), source:getHeight())
local bmp = Bitmap.new(rt)
local previous_x, previous_y = source:getPosition()
source:setPosition(0,0)
rt:draw(source)
source:setPosition(previous_x,previous_x)
stage:addChild(bmp) |
Comments
you could have an additional dummy sprite which contains your sprite, and only you move this dummy sprite. then when rendering the sprite itself it won't be moved.
Likes: totebo
Fragmenter - animated loop machine and IKONOMIKON - the memory game
The 2nd example whilst working is not very optimal. A better way would be..
In this case it would be ok, because the moving around would happen before the game starts. But if I were to do the same with game objects within the game world it might cause issues because I've overridden their setPosition() function.
You asked.
This is my dream:
https://deluxepixel.com
https://deluxepixel.com
So why not just use the provided TileMap renderer? It seems to me to be terribly fast. Am I missing something? When you say "it's slow" do you mean with your current RenderTarget system, or the provided TileMap renderer?