Exemplo n.º 1
0
 public void addAnimation(StandardSpriteAnimations animation,
                          StandardSpriteOrientations orientation,
                          Point2D movement,
                          params int[] frames)
 {
     addAnimation(SpriteHelper.GetAnimationName(animation, orientation), movement, frames);
 }
Exemplo n.º 2
0
        private void CreateLayerFromImageSet()
        {
            string preCompiledImageName = null, preCompiledFrameLutName = null;
            Bitmap sheet = null;

            if (layerPreCompile)
            {
                //if any source file is modified, the hash changes and we force a re-compile.
                unchecked
                {
                    int hash = FileHash + layerFrames.Select(L => getNameDateHash(L)).Aggregate(0, (result, element) => result + element);
                    hash = Math.Abs(hash);
                    preCompiledImageName = string.Format("{0}_precompile({2})_{1}.png", layerName, hash, precomplieTag);
                }
                //preCompiledImageName = Path.Combine("PreCompiledSprites", preCompiledImageName);

                preCompiledImageName = Path.Combine((this.PreCompiledDir ?? "PreCompiledSprites"), preCompiledImageName);


                if (File.Exists(preCompiledImageName))
                {
                    sheet = ((Bitmap)Bitmap.FromFile(preCompiledImageName)).GetUnFuckedVersion();
                }
                else
                {
                    //clean
                    string   pattern  = string.Format("{0}_precompile({1})_*.png", layerName, precomplieTag);
                    string[] oldFIles = Directory.GetFiles(Path.GetDirectoryName(preCompiledImageName), pattern);
                    foreach (string file in oldFIles)
                    {
                        File.Delete(file);
                    }
                }
            }

            if (sheet == null)
            {
                SpriteHelper.CombinedSpriteSheet cSprite = SpriteHelper.CombineSpritesSheets(
                    layerParsedImagePaths,
                    Value.SpriteSize,
                    preCompiledImageName);
                sheet = cSprite.Image;
            }

            LayeredSpriteLayer layer = new LayeredSpriteLayer(layerName, sheet);

            //for(int i=0; i<Value.Animations)
            //{
            //}
            Value.Layers.Add(layer);
        }
Exemplo n.º 3
0
        public bool ReloadFile(string path)
        {
            this.FileName = path;
            Bitmap img = Bitmap.FromFile(path) as Bitmap;

            if (img != null)
            {
                img   = img.GetUnFuckedVersion();
                Image = img;

                FrameBounds = SpriteHelper.CalcFrameBounds(img, SpriteWidth, SpriteHeight);
                return(true);
            }
            WDAppLog.logFileOpenError(ErrorLevel.Error, path);
            return(false);
        }
Exemplo n.º 4
0
 public bool ReloadFile(string path)
 {
     FrameBounds = SpriteHelper.CalcFrameBounds(Layers[0].Image, SpriteWidth, SpriteHeight);
     return(true);
 }