Пример #1
0
    private void onStartButtonTriggered( CEvent e )
    {
        mStartButton.enabled = false;
        resetEgg();

        // get next transition style from array and enqueue it at the end
        var transition = mTransitions[0];
        mTransitions.RemoveAt(0);
        mTransitions.Add(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.0f, 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", 90f); // conventional 'animate' call
        tween.moveTo(600f, 720f);       // convenience method for animating 'x' and 'y'
        tween.scaleTo(0.5f);             // convenience method for 'scaleX' and 'scaleY'
        tween.onComplete = new callbackDelegate(resetStartBtn);

        // 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 = transition;
        mTransitionLabel.alpha = 1.0f;

        var hideTween = new Tween(mTransitionLabel, 2.0f, Transitions.EASE_IN);
        hideTween.animate("alpha", 0.0f);
        Starling.juggler.add(hideTween);

        /*
        Starling.juggler.tween(mEgg, 2.0f, new TweenParams(){
            {"delay",2.0f},{"x",600f},{"y",720f},{"scaleX",0.5f},{"scaleY",0.5f}
        });
        */
    }