Esempio n. 1
0
        static void InitGradientArrays(
            LinearGradientBrush brush,
            out Avm.Array colors,
            out Avm.Array alphas,
            out Avm.Array ratios)
        {
            colors = new Avm.Array();
            alphas = new Avm.Array();
            ratios = new Avm.Array();

            var cb = brush.InterpolationColors;

            if (cb != null)
            {
                int n = cb.Colors.Length;
                for (int i = 0; i < n; ++i)
                {
                    var c = cb.Colors[i];
                    AddColor(colors, alphas, c);
                    ratios.push((uint)(cb.Positions[i] * 255));
                }
            }
            else
            {
                var c1 = brush.LinearColors[0];
                var c2 = brush.LinearColors[1];
                AddColor(colors, alphas, c1);
                AddColor(colors, alphas, c2);
                ratios.push(0);
                ratios.push(255);
            }
        }
Esempio n. 2
0
        private void onStartButtonTriggered(Event e)
        {
            mStartButton.enabled = false;
            resetEgg();

            // get next transition style from array and enqueue it at the end
            var transition = mTransitions.shift();

            mTransitions.push(transition);

            // to animate any numeric property of an arbitrary object (not just display objects!),
            // you can create a 'Tween'. One tween object animates one target for a certain time,
            // a with certain transition function.
            var tween = new Tween(mEgg, 2.0, transition);

            // you can animate any property as long as it's numeric (int, uint, Number).
            // it is animated from it's current value to a target value.
            tween.animate("rotation", starling.utils.Global.deg2rad(90)); // conventional 'animate' call
            tween.moveTo(300, 360);                                       // convenience method for animating 'x' and 'y'
            tween.scaleTo(0.5);                                           // convenience method for 'scaleX' and 'scaleY'
            tween.onComplete = (Action)(() => { mStartButton.enabled = true; });

            // the tween alone is useless -- for an animation to be carried out, it has to be
            // advance once in every frame.
            // This is done by the 'Juggler'. It receives the tween and will carry it out.
            // We use the default juggler here, but you can create your own jugglers, as well.
            // That way, you can group animations into logical parts.
            Starling.__juggler.add(tween);

            // show which tweening function is used
            mTransitionLabel.text  = (string)transition;
            mTransitionLabel.alpha = 1.0;

            var hideTween = new Tween(mTransitionLabel, 2.0, Transitions.EASE_IN);

            hideTween.animate("alpha", 0.0);
            Starling.__juggler.add(hideTween);
        }
Esempio n. 3
0
 static void AddColor(Avm.Array colors, Avm.Array alphas, Color c)
 {
     colors.push(ColorHelper.ToFlash(c));
     alphas.push(c.A / 255.0);
 }