public override void SetTarget(MGNode node) { FirstTick = true; _isEnd = false; Target = node; OrgFS = (Target as MGSprite).FS; ((MGSprite)Target).AddAnimation(Anim); }
public MGColorNode() { FS = DataManager.GetFS("PixelTexture"); Texture = FS.Texture; Left = FS.TextCoords.X; Top = FS.TextCoords.Y; Height = FS.Height; Width = FS.Width; _anchorPoisiton = FS.Anchor; }
public void InitButtonWithTextureTwinkle(string fsName1, string fsName2) { FS = DataManager.GetFS(fsName1); var anim = new MGAnimation("Frame", 0.1f, new[] { fsName1, fsName2 }); var sprite = new MGSprite(); sprite.AddAnimation(anim); sprite.SetFrame("Frame", 0); ButtonElement.Add("Image", sprite); base.AddChild(sprite, 0); Width = sprite.Width; Height = sprite.Height; base.Anchor = new Vector2(Width / 2f, Height / 2f); MGAction action = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 1) }); action.AssignTarget(sprite); MGAction action2 = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); action2.AssignTarget(sprite); MGAction action3 = MGSequence.Actions(new MGAction[] { MGRepeat.Actions(MGAnimate.ActionWithAnimation(anim), 1), MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); action3.AssignTarget(sprite); TouchBeganAction.Add("Image", action); TouchMoveOutAction.Add("Image", action2); TouchClickedAction.Add("Image", action3); }
public bool initWithFrames(List<MGSpriteFrame> pFrames, float delay) { m_fDelay = delay; m_pobFrames = pFrames; _name = "1"; foreach (var frame in pFrames) { var fs = new FrameStruct(); fs.Anchor = new Vector2(0.5f, .5f); fs.Height = frame.Rect.Height; fs.Width = frame.Rect.Width; fs.Texture = frame.Texture; fs.TextCoords = new Vector2(frame.Rect.X, frame.Rect.Y); _fsList.Add(fs); _timeList.Add(.2f); TotalDuration += 0.2f; } _duration = TotalDuration; return true; }