コード例 #1
0
 public PreRenderEffect(string n, int w, int h)
     : base(null, 0)
 {
     name = n;
     animation = new CharacterAnimation(name);
     framesize.X = w;
     framesize.Y = h;
 }
コード例 #2
0
        public void Initialize(ContentManager content)
        {
            string assertname = "effect/" + name;

            animation = new CharacterAnimation(name);
            PreRenderEffectContent.FrameDef[] defs = content.Load<PreRenderEffectContent.FrameDef[]>(assertname);
            animation.FrameCount = defs.Length;
            animation.Speed = playspeed;
            foreach (PreRenderEffectContent.FrameDef def in defs)
            {
                animation.AddFrame(def.x, def.y, def.w, def.h, "center");
            }
            animation.Reset();

            assertname = "effect/" + name + "_pic";
            texture = content.Load<Texture2D>(assertname);
        }
コード例 #3
0
 public void Initialize(CharacterDefinition.PicDef pd)
 {
     Texture2D tex = GameConst.Content.Load<Texture2D>(@"character/" + pd.texture);
     framesize.X = pd.width;
     framesize.Y = pd.height;
     Size = new Vector2(pd.size, pd.size);
     foreach (CharacterDefinition.AnimDef ad in pd.anims)
     {
         CharacterAnimation cani = new CharacterAnimation(ad.name);
         cani.FrameCount = ad.framecount;
         cani.EventFrame = ad.eventframe;
         cani.Loop = ad.loop;
         cani.Speed = ad.speed;
         foreach (CharacterDefinition.AnimFrameDef fd in ad.frames)
         {
             cani.AddFrame(fd.x, fd.y, fd.w, fd.h, fd.center);
             cani.Reset();
         }
         Animations[ad.name] = cani;
         animTextures[ad.name] = tex;
     }
     currentAnim = Animations["Idle"];
 }
コード例 #4
0
 public bool SetCurrentAnimationByName(string name/*, float speed, bool loop*/)
 {
     if (currentAnim.Name == name)
         return true;
     if (Animations.ContainsKey(name))
     {
         currentAnim = Animations[name];
         //currentAnim.Speed = speed * currentAnim.Speed;
         //currentAnim.Loop = loop;
         currentAnim.Reset();
         return true;
     }
     Log.WriteLine(string.Format("Invalid animation name {0}", name));
     return false;
 }
コード例 #5
0
 public void AddCharacterDefinition(CharacterDefinition.PicDef pd)
 {
     Texture2D tex = GameConst.Content.Load<Texture2D>(@"character/" + pd.texture);
     if (tex != null)
     {
         foreach (CharacterDefinition.AnimDef ad in pd.anims)
         {
             CharacterAnimation cani = new CharacterAnimation(ad.name);
             cani.FrameCount = ad.framecount;
             cani.EventFrame = ad.eventframe;
             cani.Loop = ad.loop;
             cani.Speed = ad.speed;
             foreach (CharacterDefinition.AnimFrameDef fd in ad.frames)
             {
                 cani.AddFrame(fd.x, fd.y, fd.w, fd.h, fd.center);
                 cani.Reset();
             }
             Animations[ad.name] = cani;
             animTextures[ad.name] = tex;
         }
     }
 }