Add() public method

Add animation for certain activity from a file
public Add ( Backend activity, Backend direction, string filename, Backend startPos, int cols = 1, int rows = 1, Backend offset = null, Backend crop = null, bool vertical = false ) : void
activity Backend
direction Backend
filename string
startPos Backend
cols int
rows int
offset Backend
crop Backend
vertical bool
return void
コード例 #1
0
        private static void _AddActivity(ContentManager _content, ActorView actor, string character, string action, Backend.Activity activity)
        {
            if (System.IO.File.Exists(".\\content\\" + character + "-" + action + ".xnb"))
            {
                try
                {
                    Texture2D texture = _content.Load<Texture2D>(character + "-" + action);
                    int size = texture.Height / 8;
                    int cols = texture.Width / size;
                    actor.width = size;
                    actor.height = size;
                    int diff = 0;
                    if (size < 128)
                    {
                        diff = 128 - size;
                    }

                    // add offset / crop
                    actor.Add(activity, Backend.Direction.DownRight, character + "-" + action, new Backend.Coords(size * 0, size * 0), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                    actor.Add(activity, Backend.Direction.UpRight, character + "-" + action, new Backend.Coords(size * 0, size * 1), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.Right, character + "-" + action, new Backend.Coords(size * 0, size * 2), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK
                    actor.Add(activity, Backend.Direction.Up, character + "-" + action, new Backend.Coords(size * 0, size * 3), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.DownLeft, character + "-" + action, new Backend.Coords(size * 0, size * 4), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.Down, character + "-" + action, new Backend.Coords(size * 0, size * 5), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                    actor.Add(activity, Backend.Direction.Left, character + "-" + action, new Backend.Coords(size * 0, size * 6), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK
                    actor.Add(activity, Backend.Direction.UpLeft, character + "-" + action, new Backend.Coords(size * 0, size * 7), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                }
                catch
                {

                }
                _content.Unload();
            }
        }