I have a source TextureAtlas file that I want to copy each individual sprite from and paste onto a new frame on a new (aseprite) sprite. It works fine when ddata.target == "Layers"
, but the position isn’t set when ddata.target == "Frames"
. What should I be doing instead?
source_sprite.selection:select(Rectangle(x, y, width, height))
app.sprite = source_sprite
app.command.CopyMerged()
app.sprite = new_sprite
if ddata.target == "Layers" then
-- copy sprites to layers
app.command.NewLayer { fromClipboard = true }
app.activeLayer.name = xml_sprite["name"]
elseif ddata.target == "Frames" then
-- copy sprites to frames
new_sprite:newEmptyFrame()
app.cel = new_sprite:newCel(app.activeLayer, app.frame)
app.command.Paste()
end
local new_x = xml_sprite["frameX"] * -1
local new_y = xml_sprite["frameY"] * -1
local cel = app.cel
cel.position = Point(new_x, new_y)
Full code here: GitHub - cndofx/aseprite-xml-textureatlas-splitter: an aseprite script to split a TextureAtlas with an accompanying XML file