Jump to content
  • 0

Help: Multi image sprite


EL Dragon

Question


  • Group:  Members
  • Topic Count:  86
  • Topics Per Day:  0.02
  • Content Count:  591
  • Reputation:   146
  • Joined:  06/19/12
  • Last Seen:  

is it possible 3-5 images ea Frame to use? 

 

 

 

Actor it works:

windfap679s1dv.png

 

 

in Game is only the first Image

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  663
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

Headgears only load the first layer of the frame (which is fairly annoying). There are no straightforward solutions for this, unless you don't mind remaking your act from scratch again with that into consideration.

 

The following solution will increase your sprite file size by a lot depending on how complex your frames are. The advantage is that your work will be preserved almost perfectly. Make a backup first, just to be safe. Go in Script > Script Runner... copy paste the following code, then press Run.

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;
    }
}));

This script will merge all layers of your frames into one.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  86
  • Topics Per Day:  0.02
  • Content Count:  591
  • Reputation:   146
  • Joined:  06/19/12
  • Last Seen:  

thx :) is working

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...