public void InitCheckboxWithPrssingTexture(string fsName1, string fsName2, string fsName3, string fsName4) { if (fsName3 == "" && fsName4 == "") { var sprite = new MGSprite(fsName1); var sprite2 = new MGSprite(fsName2); sprite2.Visible = false; base.AddChild(sprite, 0); base.AddChild(sprite2, 0); ButtonElement.Add("ImageOn", sprite); ButtonElement.Add("ImageOff", sprite2); Width = sprite.Width; Height = sprite.Height; base.Anchor = new Vector2(Width / 2f, Height / 2f); MGAction cDEAction = MGSequence.Actions(new MGAction[] { new MGToggleVisibility() }); cDEAction.AssignTarget(sprite); TouchClickedAction.Add("ImageOn", cDEAction); MGAction cDEAction2 = MGSequence.Actions(new MGAction[] { new MGToggleVisibility() }); cDEAction2.AssignTarget(sprite2); TouchClickedAction.Add("ImageOff", cDEAction2); return; } var anim = new MGAnimation("Frame", 0.1f, new[] { fsName1, fsName3 }); var anim2 = new MGAnimation("Frame", 0.1f, new[] { fsName2, fsName4 }); var cDESprite3 = new MGSprite(); var cDESprite4 = new MGSprite(); cDESprite3.AddAnimation(anim); cDESprite4.AddAnimation(anim2); cDESprite3.SetFrame("Frame", 0); cDESprite4.SetFrame("Frame", 0); base.AddChild(cDESprite3, 0); base.AddChild(cDESprite4, 0); cDESprite4.Visible = false; ButtonElement.Add("ImageOn", cDESprite3); ButtonElement.Add("ImageOff", cDESprite4); Width = cDESprite3.Width; Height = cDESprite3.Height; base.Anchor = new Vector2(Width / 2f, Height / 2f); MGAction cDEAction3 = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 1) }); cDEAction3.AssignTarget(cDESprite3); MGAction cDEAction4 = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); cDEAction4.AssignTarget(cDESprite3); MGAction cDEAction5 = MGSequence.Actions(new MGAction[] { new MGToggleVisibility(), MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); cDEAction5.AssignTarget(cDESprite3); TouchBeganAction.Add("ImageOn", cDEAction3); TouchMoveOutAction.Add("ImageOn", cDEAction4); TouchClickedAction.Add("ImageOn", cDEAction5); MGAction cDEAction6 = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 1) }); cDEAction6.AssignTarget(cDESprite4); MGAction cDEAction7 = MGSequence.Actions(new MGAction[] { MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); cDEAction7.AssignTarget(cDESprite4); MGAction cDEAction8 = MGSequence.Actions(new MGAction[] { new MGToggleVisibility(), MGFrameAction.ActionWithAnimationIndex("Frame", 0) }); cDEAction8.AssignTarget(cDESprite4); TouchBeganAction.Add("ImageOff", cDEAction6); TouchMoveOutAction.Add("ImageOff", cDEAction7); TouchClickedAction.Add("ImageOff", cDEAction8); }
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); }