Ejemplo n.º 1
0
 /// <summary>
 /// トラックの削除
 /// </summary>
 /// <remarks>
 /// 登録されていなかったトラックの削除は安全に無視します。
 /// </remarks>
 /// <param name="track">削除したいトラック</param>
 /// <returns>削除したら <c>true</c>、そうでなければ <c>false</c>。</returns>
 public int RemoveTrack(AnimationTrack track)
 {
     return this.tracks.RemoveAll (x => x.Item2 == track);
 }
Ejemplo n.º 2
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyCharacter ();

            var spr1 = new Sprite (new Texture ("media/Character-Gelato.png"), 24, 32);
            var spr2 = new Sprite (new Texture ("media/Image128x128(Red).png"), 24, 4);
            spr2.SetOffset (0, spr1.Height);

            var body = new BoxCollision (spr1.Width / 2, spr1.Height / 2, 0);
            var foot = new SphereCollision (2);
            body.SetOffset (spr1.Width / 2, spr1.Height / 2, 0);
            foot.SetOffset (spr1.Width / 2, spr1.Height + 2, 0);

            var node = new Node ("MyCharacter");
            node.Attach (spr1);
            node.Attach (spr2);
            node.Attach (body);
            node.Attach (foot);
            node.Attach (cmp);

            node.DrawPriority = -1;
            node.Translation = pos;

            cmp.jumpSound = new SoundClip ("JumpSound");
            cmp.jumpSound.AddTrack (new SoundEffectTrack ("media/Jump.ogg"));

            var track1 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track1.AddKeyframe (0, new Vector2 (0, 64));
            track1.AddKeyframe (300, new Vector2 (24, 64));
            track1.AddKeyframe (600, new Vector2 (48, 64));
            cmp.walkDown = new AnimationClip (900, "MyCharacter.Down");
            cmp.walkDown.AddTrack (spr1, track1);

            var track2 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track2.AddKeyframe (0, new Vector2 (0, 0));
            track2.AddKeyframe (300, new Vector2 (24, 0));
            track2.AddKeyframe (600, new Vector2 (48, 0));
            cmp.walkUp = new AnimationClip (900, "MyCharacter.Up");
            cmp.walkUp.AddTrack (spr1, track2);

            var track3 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track3.AddKeyframe (0, new Vector2 (0, 32));
            track3.AddKeyframe (300, new Vector2 (24, 32));
            track3.AddKeyframe (600, new Vector2 (48, 32));
            cmp.walkRight = new AnimationClip (900, "MyCharacter.Right");
            cmp.walkRight.AddTrack (spr1, track3);

            var track4 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track4.AddKeyframe (0, new Vector2 (0, 96));
            track4.AddKeyframe (300, new Vector2 (24, 96));
            track4.AddKeyframe (600, new Vector2 (48, 96));
            cmp.walkLeft = new AnimationClip (900, "MyCharacter.Left");
            cmp.walkLeft.AddTrack (spr1, track4);

            return node;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// トラックの追加
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="target">ターゲット オブジェクト</param>
 /// <param name="track">追加したいトラック</param>
 public void AddTrack(object target, AnimationTrack track)
 {
     if (target == null) {
         throw new ArgumentNullException ("Target is null");
     }
     if (track == null) {
         throw new ArgumentNullException ("Track is null");
     }
     this.tracks.Add (Tuple.Create (new WeakReference (target), track));
 }