Пример #1
0
        public void InitButtonWithTextureTwinkle(string fsName1, string fsName2)
        {
            this.fs = LNDataCache.GetFrameStruct(fsName1);
            LNAnimation anim   = new LNAnimation("Frame", 0.1f, fsName1, fsName2);
            LNSprite    sprite = new LNSprite();

            sprite.AddAnimation(anim);
            sprite.SetFrame("Frame", 0);
            CollectionUtils.Put(this._buttonElement, "Image", sprite);
            base.AddNode(sprite, 0);
            base.SetNodeSize(sprite.GetWidth(), sprite.GetHeight());
            base.SetAnchor(new Vector2f(base.GetWidth() / 2f,
                                        base.GetHeight() / 2f));
            LNAction action = LNSequence.Action(LNFrameAction.Action("Frame", 1));

            action.AssignTarget(sprite);
            LNAction action2 = LNSequence.Action(LNFrameAction.Action("Frame", 0));

            action2.AssignTarget(sprite);
            LNAction action3 = LNSequence.Action(
                LNRepeat.Action(LNAnimate.Action(anim), 1),
                LNFrameAction.Action("Frame", 0));

            action3.AssignTarget(sprite);
            CollectionUtils.Put(this._touchBeganAction, "Image", action);
            CollectionUtils.Put(this._touchMoveOutAction, "Image", action2);
            CollectionUtils.Put(this._touchClickedAction, "Image", action3);
        }
Пример #2
0
        public static LNSprite GInitWithAnimation(LNAnimation ans)
        {
            LNSprite sprite = new LNSprite();

            sprite.InitWithAnimation(ans, 0);
            return(sprite);
        }
Пример #3
0
 public void SetFrame(string animName, int index)
 {
     if (this._anims == null)
     {
         this._anims = new System.Collections.Generic.Dictionary <string, LNAnimation>();
     }
     if (this._anims.ContainsKey(animName))
     {
         this._ans = (LNAnimation)CollectionUtils.Get(this._anims, animName);
         InitWithAnimation(this._ans, index);
     }
 }
Пример #4
0
 public void InitWithAnimation(LNAnimation ans, int idx)
 {
     if (ans != null)
     {
         if (this._anims == null)
         {
             this._anims = new System.Collections.Generic.Dictionary <string, LNAnimation>();
         }
         this._ans = ans;
         InitWithFrameStruct(this._ans.GetFrame(idx));
         CollectionUtils.Put(_anims, ans.GetName(), ans);
     }
 }
Пример #5
0
        public override void DefinitionObjectDidReceiveString(string v)
        {
            base.DefinitionObjectDidReceiveString(v);
            List <string> result = GetResult(v);
            float         time   = 3f;

            foreach (string list in result)
            {
                if (list.Length > 2)
                {
                    string[] values = StringUtils.Split(list, "=");
                    string   name   = values[0];
                    string   value  = values[1];
                    if ("id".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.uniqueID = value;
                    }
                    else if ("animationid".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.uniqueID = value;
                    }
                    else if ("time".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        time = Convert.ToSingle(value);
                    }
                    else if ("duration".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        time = Convert.ToSingle(value);
                    }
                    else if ("list".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (animation == null)
                        {
                            animation = new LNAnimation();
                        }
                        animation._name = uniqueID;
                        string[] lists = StringUtils.Split(list, ",");
                        for (int i = 0; i < lists.Length; i++)
                        {
                            animation.AddFrameStruct(lists[i], time);
                        }
                    }
                }
            }
            result.Clear();
        }
Пример #6
0
 public override void DefinitionObjectDidReceiveString(string v)
 {
     base.DefinitionObjectDidReceiveString(v);
     List<string> result = GetResult(v);
     float time = 3f;
     foreach (string list in result)
     {
         if (list.Length > 2)
         {
             string[] values = StringUtils.Split(list, "=");
             string name = values[0];
             string value = values[1];
             if ("id".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
             {
                 this.uniqueID = value;
             }
             else if ("animationid".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
             {
                 this.uniqueID = value;
             }
             else if ("time".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
             {
                 time = Convert.ToSingle(value);
             }
             else if ("duration".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
             {
                 time = Convert.ToSingle(value);
             }
             else if ("list".Equals(name, System.StringComparison.InvariantCultureIgnoreCase))
             {
                 if (animation == null)
                 {
                     animation = new LNAnimation();
                 }
                 animation._name = uniqueID;
                 string[] lists = StringUtils.Split(list, ",");
                 for (int i = 0; i < lists.Length; i++)
                 {
                     animation.AddFrameStruct(lists[i], time);
                 }
             }
         }
     }
     result.Clear();
 }
Пример #7
0
 public LNSprite(string fsName)
     : base()
 {
     this._ans = null;
     LNFrameStruct struc0 = LNDataCache.GetFrameStruct(fsName);
     if (struc0 == null)
     {
         throw new Exception("");
     }
     this._texture = struc0._texture;
     base._left = struc0._textCoords.X();
     base._top = struc0._textCoords.Y();
     base._orig_width = struc0._orig_width;
     base._orig_height = struc0._orig_height;
     base.SetNodeSize(struc0._size_width, struc0._size_height);
     base._anchor.Set(struc0._anchor);
     blendState = struc0._state;
     if (!struc0._place.Equals(0, 0))
     {
         SetPosition(struc0._place);
     }
 }
Пример #8
0
        public LNSprite(string fsName)
            : base()
        {
            this._ans = null;
            LNFrameStruct struc0 = LNDataCache.GetFrameStruct(fsName);

            if (struc0 == null)
            {
                throw new Exception("");
            }
            this._texture     = struc0._texture;
            base._left        = struc0._textCoords.X();
            base._top         = struc0._textCoords.Y();
            base._orig_width  = struc0._orig_width;
            base._orig_height = struc0._orig_height;
            base.SetNodeSize(struc0._size_width, struc0._size_height);
            base._anchor.Set(struc0._anchor);
            blendState = struc0._state;
            if (!struc0._place.Equals(0, 0))
            {
                SetPosition(struc0._place);
            }
        }
Пример #9
0
		public void InitCheckboxWithPrssingTexture(string fsName1, string fsName2,
				string fsName3, string fsName4) {
			if ((fsName3.Equals("")) && (fsName4.Equals(""))) {
				LNSprite node = new LNSprite(fsName1);
				LNSprite sprite2 = new LNSprite(fsName2);
				sprite2.SetVisible(false);
				base.AddNode(node,0);
				base.AddNode(sprite2,0);
				CollectionUtils.Put(this._buttonElement,"ImageOn",node);
				CollectionUtils.Put(this._buttonElement,"ImageOff",sprite2);
				base.SetNodeSize(node.GetWidth(),node.GetHeight());
				base.SetAnchor(new Vector2f(base.GetWidth() / 2f, base.GetHeight() / 2f));
				LNAction action = LNSequence.Action(LNToggleVisibility.Action());
				action.AssignTarget(node);
				CollectionUtils.Put(this._touchClickedAction,"ImageOn",action);
				LNAction action2 = LNSequence.Action(LNToggleVisibility.Action());
				action2.AssignTarget(sprite2);
				CollectionUtils.Put(this._touchClickedAction,"ImageOff",action2);
			} else {
				LNAnimation anim = new LNAnimation("Frame", 0.1f, new string[] {
						fsName1, fsName3 });
				LNAnimation animation2 = new LNAnimation("Frame", 0.1f,
						new string[] { fsName2, fsName4 });
				LNSprite sprite3 = new LNSprite();
				LNSprite sprite4 = new LNSprite();
				sprite3.AddAnimation(anim);
				sprite4.AddAnimation(animation2);
				sprite3.SetFrame("Frame", 0);
				sprite4.SetFrame("Frame", 0);
				base.AddNode(sprite3,0);
				base.AddNode(sprite4,0);
				sprite4.SetVisible(false);
				CollectionUtils.Put(this._buttonElement,"ImageOn",sprite3);
				CollectionUtils.Put(this._buttonElement,"ImageOff",sprite4);
				base.SetNodeSize(sprite3.GetWidth(),sprite3.GetHeight());
				base.SetAnchor(new Vector2f(base.GetWidth() / 2f, base.GetHeight() / 2f));
				LNAction action3 = LNSequence.Action(LNFrameAction.Action("Frame",
						1));
				action3.AssignTarget(sprite3);
				LNAction action4 = LNSequence.Action(LNFrameAction.Action("Frame",
						0));
				action4.AssignTarget(sprite3);
				LNAction action5 = LNSequence.Action(LNToggleVisibility.Action(),
						LNFrameAction.Action("Frame", 0));
				action5.AssignTarget(sprite3);
				CollectionUtils.Put(this._touchBeganAction,"ImageOn",action3);
				CollectionUtils.Put(this._touchMoveOutAction,"ImageOn",action4);
				CollectionUtils.Put(this._touchClickedAction,"ImageOn",action5);
				LNAction action6 = LNSequence.Action(LNFrameAction.Action("Frame",
						1));
				action6.AssignTarget(sprite4);
				LNAction action7 = LNSequence.Action(LNFrameAction.Action("Frame",
						0));
				action7.AssignTarget(sprite4);
				LNAction action8 = LNSequence.Action(LNToggleVisibility.Action(),
						LNFrameAction.Action("Frame", 0));
				action8.AssignTarget(sprite4);
				CollectionUtils.Put(this._touchBeganAction,"ImageOff",action6);
				CollectionUtils.Put(this._touchMoveOutAction,"ImageOff",action7);
				CollectionUtils.Put(this._touchClickedAction,"ImageOff",action8);
			}
		}
Пример #10
0
		public void InitButtonWithTextureTwinkle(string fsName1, string fsName2) {
			this.fs = LNDataCache.GetFrameStruct(fsName1);
			LNAnimation anim = new LNAnimation("Frame", 0.1f, fsName1, fsName2);
			LNSprite sprite = new LNSprite();
			sprite.AddAnimation(anim);
			sprite.SetFrame("Frame", 0);
			CollectionUtils.Put(this._buttonElement,"Image",sprite);
			base.AddNode(sprite,0);
			base.SetNodeSize(sprite.GetWidth(),sprite.GetHeight());
			base.SetAnchor(new Vector2f(base.GetWidth() / 2f,
							base.GetHeight() / 2f));
			LNAction action = LNSequence.Action(LNFrameAction.Action("Frame", 1));
			action.AssignTarget(sprite);
			LNAction action2 = LNSequence.Action(LNFrameAction.Action("Frame", 0));
			action2.AssignTarget(sprite);
			LNAction action3 = LNSequence.Action(
					LNRepeat.Action(LNAnimate.Action(anim), 1),
					LNFrameAction.Action("Frame", 0));
			action3.AssignTarget(sprite);
			CollectionUtils.Put(this._touchBeganAction,"Image",action);
			CollectionUtils.Put(this._touchMoveOutAction,"Image",action2);
			CollectionUtils.Put(this._touchClickedAction,"Image",action3);
		}
Пример #11
0
		public void AddAnimation(LNAnimation anim) {
			InitWithAnimation(anim, 0);
		}
Пример #12
0
 public LNSprite(int x, int y, int w, int h) : base(x, y, w, h)
 {
     this._ans    = null;
     base._anchor = new Vector2f(0f, 0f);
 }
Пример #13
0
 public void SetAnimation(LNAnimation ans)
 {
     this._ans = ans;
     this.InitWithTexture(this._ans.GetFrame(0)._texture);
 }
Пример #14
0
 public LNSprite(RectBox rect) : base(rect)
 {
     this._ans    = null;
     base._anchor = new Vector2f(0f, 0f);
 }
Пример #15
0
		public void SetFrame(string animName, int index) {
			if (this._anims == null) {
                this._anims = new System.Collections.Generic.Dictionary<string, LNAnimation>();
			}
			if (this._anims.ContainsKey(animName)) {
				this._ans = (LNAnimation)CollectionUtils.Get(this._anims,animName);
				InitWithAnimation(this._ans, index);
			}
		}
Пример #16
0
		public void InitWithAnimation(LNAnimation ans, int idx) {
			if (ans != null) {
				if (this._anims == null) {
					this._anims = new System.Collections.Generic.Dictionary<string, LNAnimation>();
				}
				this._ans = ans;
				InitWithFrameStruct(this._ans.GetFrame(idx));
				CollectionUtils.Put(_anims,ans.GetName(),ans);
			}
		}
Пример #17
0
		public void SetAnimation(LNAnimation ans) {
			this._ans = ans;
			this.InitWithTexture(this._ans.GetFrame(0)._texture);
		}
Пример #18
0
		public static LNSprite GInitWithAnimation(LNAnimation ans) {
			LNSprite sprite = new LNSprite();
			sprite.InitWithAnimation(ans, 0);
			return sprite;
		}
Пример #19
0
		public LNSprite(int x, int y, int w, int h):base(x,y,w,h) {
			this._ans = null;
			base._anchor = new Vector2f(0f, 0f);
		}
Пример #20
0
		public LNSprite(RectBox rect):base(rect) {
			this._ans = null;
			base._anchor = new Vector2f(0f, 0f);
		}
Пример #21
0
 public void InitCheckboxWithPrssingTexture(string fsName1, string fsName2,
                                            string fsName3, string fsName4)
 {
     if ((fsName3.Equals("")) && (fsName4.Equals("")))
     {
         LNSprite node    = new LNSprite(fsName1);
         LNSprite sprite2 = new LNSprite(fsName2);
         sprite2.SetVisible(false);
         base.AddNode(node, 0);
         base.AddNode(sprite2, 0);
         CollectionUtils.Put(this._buttonElement, "ImageOn", node);
         CollectionUtils.Put(this._buttonElement, "ImageOff", sprite2);
         base.SetNodeSize(node.GetWidth(), node.GetHeight());
         base.SetAnchor(new Vector2f(base.GetWidth() / 2f, base.GetHeight() / 2f));
         LNAction action = LNSequence.Action(LNToggleVisibility.Action());
         action.AssignTarget(node);
         CollectionUtils.Put(this._touchClickedAction, "ImageOn", action);
         LNAction action2 = LNSequence.Action(LNToggleVisibility.Action());
         action2.AssignTarget(sprite2);
         CollectionUtils.Put(this._touchClickedAction, "ImageOff", action2);
     }
     else
     {
         LNAnimation anim = new LNAnimation("Frame", 0.1f, new string[] {
             fsName1, fsName3
         });
         LNAnimation animation2 = new LNAnimation("Frame", 0.1f,
                                                  new string[] { fsName2, fsName4 });
         LNSprite sprite3 = new LNSprite();
         LNSprite sprite4 = new LNSprite();
         sprite3.AddAnimation(anim);
         sprite4.AddAnimation(animation2);
         sprite3.SetFrame("Frame", 0);
         sprite4.SetFrame("Frame", 0);
         base.AddNode(sprite3, 0);
         base.AddNode(sprite4, 0);
         sprite4.SetVisible(false);
         CollectionUtils.Put(this._buttonElement, "ImageOn", sprite3);
         CollectionUtils.Put(this._buttonElement, "ImageOff", sprite4);
         base.SetNodeSize(sprite3.GetWidth(), sprite3.GetHeight());
         base.SetAnchor(new Vector2f(base.GetWidth() / 2f, base.GetHeight() / 2f));
         LNAction action3 = LNSequence.Action(LNFrameAction.Action("Frame",
                                                                   1));
         action3.AssignTarget(sprite3);
         LNAction action4 = LNSequence.Action(LNFrameAction.Action("Frame",
                                                                   0));
         action4.AssignTarget(sprite3);
         LNAction action5 = LNSequence.Action(LNToggleVisibility.Action(),
                                              LNFrameAction.Action("Frame", 0));
         action5.AssignTarget(sprite3);
         CollectionUtils.Put(this._touchBeganAction, "ImageOn", action3);
         CollectionUtils.Put(this._touchMoveOutAction, "ImageOn", action4);
         CollectionUtils.Put(this._touchClickedAction, "ImageOn", action5);
         LNAction action6 = LNSequence.Action(LNFrameAction.Action("Frame",
                                                                   1));
         action6.AssignTarget(sprite4);
         LNAction action7 = LNSequence.Action(LNFrameAction.Action("Frame",
                                                                   0));
         action7.AssignTarget(sprite4);
         LNAction action8 = LNSequence.Action(LNToggleVisibility.Action(),
                                              LNFrameAction.Action("Frame", 0));
         action8.AssignTarget(sprite4);
         CollectionUtils.Put(this._touchBeganAction, "ImageOff", action6);
         CollectionUtils.Put(this._touchMoveOutAction, "ImageOff", action7);
         CollectionUtils.Put(this._touchClickedAction, "ImageOff", action8);
     }
 }
Пример #22
0
 public void AddAnimation(LNAnimation anim)
 {
     InitWithAnimation(anim, 0);
 }