Jump to content
  • 0
Sign in to follow this  
Promeister

Multiple Layering in ACT Editor how?

Question

HI! I was wondering how some .act's have multiple layers but when i tried to customize my own multiple layered .act's, it only saves the first sprite and always gives me warnings that there are multiple layers and it will not show. Can anyone assists me here? THANK YOU!

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

run this script on act editor - credits goes to tokei

int count = act.GetAllFrames().Count + 1;
int index = 0;

TaskManager.DisplayTaskC("Rendering frames...", "Please wait...", () => index, count, new Action<Func<bool>>(isCancelling => {
try {
foreach (var action in act) {
foreach (var frame in action) {
if (frame.Layers.Count <= 1) {
index++;
continue;
}
if (isCancelling()) return;

var image = frame.Render(act);
var box = ActImaging.Imaging.GenerateFrameBoundingBox(act, frame);
int relativeIndex = -1;

for (int i = 0; i < act.Sprite.Images.Count; i++) {
if (image.Equals(act.Sprite.Images[i])) {
if (isCancelling()) return;
relativeIndex = act.Sprite.AbsoluteToRelative(i, act.Sprite.Images[i].GrfImageType == GrfImageType.Indexed8 ? 0 : 1);
}
}

if (relativeIndex < 0) {
relativeIndex = act.Sprite.InsertAny(image);
}

int offsetX = (int) ((int) ((box.Max.X - box.Min.X + 1) / 2) + box.Min.X);
int offsetY = (int) ((int) ((box.Max.Y - box.Min.Y + 1) / 2) + box.Min.Y);
var layer = new Layer(relativeIndex, image);

layer.OffsetX = offsetX;
layer.OffsetY = offsetY;

frame.Layers.Clear();
frame.Layers.Add(layer);
index++;
}
}

// Removes unused sprites - old way, older versions have a bug
for (int i = act.Sprite.Images.Count - 1; i >= 0 ; i--) {
if (act.FindUsageOf(i).Count == 0) {
var type = act.Sprite.Images[i].GrfImageType;
var relativeIndex = act.Sprite.AbsoluteToRelative(i, type == GrfImageType.Indexed8 ? 0 : 1);
act.Sprite.Remove(relativeIndex, type);

if (type == GrfImageType.Indexed8) {
act.AllLayers(layer => {
if ((layer.IsIndexed8() && type == GrfImageType.Indexed8) ||
(layer.IsBgra32() && type == GrfImageType.Bgra32)) {
if (layer.SpriteIndex == relativeIndex) {
layer.SpriteIndex = -1;
}
}
});
}

act.Sprite.ShiftIndexesAbove(act, type, -1, relativeIndex);
}
}
}
finally {
index = count;
}
}));

Share this post


Link to post
Share on other sites
  • 0
On 2/22/2017 at 9:07 PM, Reins said:

run this script on act editor - credits goes to tokei

int count = act.GetAllFrames().Count + 1;
int index = 0;

TaskManager.DisplayTaskC("Rendering frames...", "Please wait...", () => index, count, new Action<Func<bool>>(isCancelling => {
try {
foreach (var action in act) {
foreach (var frame in action) {
if (frame.Layers.Count <= 1) {
index++;
continue;
}
if (isCancelling()) return;

var image = frame.Render(act);
var box = ActImaging.Imaging.GenerateFrameBoundingBox(act, frame);
int relativeIndex = -1;

for (int i = 0; i < act.Sprite.Images.Count; i++) {
if (image.Equals(act.Sprite.Images[i])) {
if (isCancelling()) return;
relativeIndex = act.Sprite.AbsoluteToRelative(i, act.Sprite.Images[i].GrfImageType == GrfImageType.Indexed8 ? 0 : 1);
}
}

if (relativeIndex < 0) {
relativeIndex = act.Sprite.InsertAny(image);
}

int offsetX = (int) ((int) ((box.Max.X - box.Min.X + 1) / 2) + box.Min.X);
int offsetY = (int) ((int) ((box.Max.Y - box.Min.Y + 1) / 2) + box.Min.Y);
var layer = new Layer(relativeIndex, image);

layer.OffsetX = offsetX;
layer.OffsetY = offsetY;

frame.Layers.Clear();
frame.Layers.Add(layer);
index++;
}
}

// Removes unused sprites - old way, older versions have a bug
for (int i = act.Sprite.Images.Count - 1; i >= 0 ; i--) {
if (act.FindUsageOf(i).Count == 0) {
var type = act.Sprite.Images[i].GrfImageType;
var relativeIndex = act.Sprite.AbsoluteToRelative(i, type == GrfImageType.Indexed8 ? 0 : 1);
act.Sprite.Remove(relativeIndex, type);

if (type == GrfImageType.Indexed8) {
act.AllLayers(layer => {
if ((layer.IsIndexed8() && type == GrfImageType.Indexed8) ||
(layer.IsBgra32() && type == GrfImageType.Bgra32)) {
if (layer.SpriteIndex == relativeIndex) {
layer.SpriteIndex = -1;
}
}
});
}

act.Sprite.ShiftIndexesAbove(act, type, -1, relativeIndex);
}
}
}
finally {
index = count;
}
}));

Hi...can you teach me how to use this script to combite multilayer sprites?

I have a problem when trying to run this script as shown below:
image.png.dcc033193c299effbeaf9f8da711adc2.png

 

Thanks for your help.
Cheers

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.