public Logo(int xPos, int yPos) : base(xPos, yPos) { loadGraphic("flixel/initials/initialsLogo"); centerAtX(); centerAtY(); t = new Tweener(0, 360, 3.0f, XNATweener.Linear.EaseInOut); t.PingPong = true; }
public static void AddTween(Tweener tweener, TweenPositionUpdate updateCallback, BasicEvent endCallback = null) { _tweens.Add(tweener); tweener.PositionChanged += new PositionChangedHandler<float>((value) => updateCallback(value)); tweener.Ended += () => { if (endCallback != null) endCallback(); _tweens.Remove(tweener); }; }
public BattleUI() : base() { int midX = (FlxG.width / 2) - (320 / 2); int midY = 10; box = new UIBox(midX, midY, 320, 180); box.setScrollFactors(0, 0); add(box); FlxText t = new FlxText(midX, midY, 320, "BATTLE"); t.setScrollFactors(0, 0); add(t); visible = false; keys = new KeyGroup(); add(keys); #if DEBUGX2 playerTweener = new Tweener(0, box.x + 50, 1.0f, Circular.EaseOut); playerTweener.Start(); targetTweener = new Tweener(FlxG.width, box.x + box.width - 50, 0.9f, Circular.EaseOut); targetTweener.Start(); #else playerTweener = new Tweener(0, box.x - 50, 1.0f, Circular.EaseOut); playerTweener.Start(); targetTweener = new Tweener(FlxG.width, box.x + box.width + 50, 0.9f, Circular.EaseOut); targetTweener.Start(); #endif directions = new int[] { FlxHud.Keyboard_Arrow_Down, FlxHud.Keyboard_Arrow_Up, FlxHud.Keyboard_Arrow_Left, FlxHud.Keyboard_Arrow_Right}; }
public Hud(int xPos, int yPos) : base(xPos, yPos) { loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/currentChar"), true, false, 14, 28); setScrollFactors(0, 0); addAnimation("andre", new int[] { 2 }, 0, true); play("andre"); coin = new Coin(FlxG.width - 24, 2, true); coin.setScrollFactors(0, 0); coinCounter = new FlxText(FlxG.width - 36, 10, 100); coinCounter.setFormat(null, 1, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Left, Lemonade_Globals.GAMEBOY_COLOR_1); coinCounter.alignment = FlxJustification.Left; coinCounter.setScrollFactors(0, 0); toastySprite = new FlxSprite(0, FlxG.height); string person = "Lemonade/illustration/andre_drawing"; int ran = (int)FlxU.random(0, 4); switch (ran) { case 0: person = "Lemonade/illustration/andre_drawing"; break; case 1: person = "Lemonade/illustration/liselot_drawing"; break; case 2: person = "Lemonade/illustration/army_drawing"; break; case 3: person = "Lemonade/illustration/worker_drawing"; break; default: person = "Lemonade/illustration/andre_drawing"; break; } toastySprite.loadGraphic(person, false, false, 302, 640); toastySprite.setScrollFactors(0, 0); tween = new Tweener(4, 12, 1, Quadratic.EaseInOut); tween.Start(); tween.PingPong = true; powerBar = new FlxGroup(); for (int i = 0; i < 30; i++) { int offsetY = 0; int offsetS = 0; #if __ANDROID__ offsetY = 50; offsetS = 150; #endif FlxSprite bar = new FlxSprite(offsetS + 5 + (i * 10), FlxG.height - 10 - offsetY); bar.createGraphic(8, 8, Lemonade_Globals.GAMEBOY_COLOR_4); bar.setScrollFactors(0, 0); powerBar.add(bar); } }
/// <summary> /// Called from parent when it closes to ensure this asset closes properly and leaves /// not possible memory leaks /// </summary> public void Unload() { WindowLayoutService.OnWindowLayoutRaised -= WindowLayoutService_OnWindowLayoutRaised; _root = null; _rootParent = null; _clearRenderTree(); ClearAssets(); _clock = null; _gt = null; _tweener = null; _deviceManager = null; _d2dContext = null; if (_stagingBitmap != null) { _stagingBitmap.Dispose(); _stagingBitmap = null; } if (_stagingBitmapSourceEffect != null) { _stagingBitmapSourceEffect.Dispose(); _stagingBitmapSourceEffect = null; } if (_stagingTexture2D != null) { _stagingTexture2D.Dispose(); _stagingTexture2D = null; } _pathD2DConverter = null; //_graphicsDevice.Dispose(); //_graphicsDevice = null; }
private void _updateBackgroundTweener(float start, float end, float duration) { //methodinfo.createdelegate //http://msdn.microsoft.com/en-us/library/windows/apps/hh194376.aspx if (_tweener == null) { _tweener = new Tweener(start, end, TimeSpan.FromSeconds(duration), (TweeningFunction)Cubic.EaseIn); _tweener.PositionChanged += (newVal) => { _updateScaleTranslate((float)newVal); }; _tweener.Ended += () => { _tweener.Pause(); }; } else { _tweener.Reset(start, end, duration); _tweener.Play(); } }
/// <summary> /// Perform a step of (visually)disposing the unit from the game. /// </summary> /// <param name="gameTime">The current game time.</param> /// <param name="duration">Duration of disposing animation in seconds.</param> /// <param name="disposeOffset">How match </param> /// <returns>Is unit already disposed?</returns> /// TODO: calculate proper offset based of world coordinates public virtual bool OnDispose(GameTime gameTime, float duration = UnitConsts.DEFAULT_DISPOSE_DURATION, float disposeOffset = 5f) { Debug.Assert(Avatar != null); if (Avatar == null) { throw new InvalidOperationException(); } Debug.Assert(duration > 0); if (_disposeTweener == null) { _disposeTweener = new Tweener(Avatar.Position.Y, (Avatar.Position.Y + disposeOffset), duration, Cubic.EaseIn); _disposeTweener.Play(); return false; } _disposeTweener.Update(gameTime); Avatar.Position = new Vector3(Avatar.Position.X, _disposeTweener.Position, Avatar.Position.Z); return !_disposeTweener.Playing; }