/// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            SetBackground(ResourceManager.CreateImage("bg_mobile"), Adjustment.CENTER);

            StripAnimation animation = new StripAnimation(1020, 868, 204, 217, 19);
            animation.FramesPerSecond = 40;
            img = ResourceManager.CreateAnimatedImage("ball");

            img.AddAnimation("bounce", animation);
            img.EndedCurrentStripAnimation += new EventHandler(img_EndedCurrentStripAnimation);
            numberPlayed = 0;
            AddComponent(new Label(img), 10, 100);
            Button play = new Button("Play");
            Button stop = new Button("Stop");
            Button pause = new Button("Pause");
            play.Released += new Component.ComponentEventHandler(play_Released);
            stop.Released += new Component.ComponentEventHandler(stop_Released);
            pause.Released += new Component.ComponentEventHandler(pause_Released);

            playNumbers = new Label("0");

            AddComponent(play, 150, 100);
            AddComponent(stop, 150, 150);
            AddComponent(pause, 150, 200);
            AddComponent(playNumbers, 10, 50);
        }
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            SetBackground(ResourceManager.CreateImage("Background"), Adjustment.CENTER);

            #region Moi
            aiMoi = ResourceManager.CreateAnimatedImage("MoiWalkingStripAnimation");

            int width = aiMoi.Width;
            int height = aiMoi.Height;

            StripAnimation saMoiWalkingFrontRight = new StripAnimation(width, height, width / 4, height / 4, 4);
            aiMoi.AddAnimation("MoiWalkingFrontRight", saMoiWalkingFrontRight);
            StripAnimation saMoiWalkingFrontLeft = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4);
            aiMoi.AddAnimation("MoiWalkingFrontLeft", saMoiWalkingFrontLeft);
            StripAnimation saMoiWalkingRearRight = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4 * 2);
            aiMoi.AddAnimation("MoiWalkingRearRight", saMoiWalkingRearRight);
            StripAnimation saMoiWalkingRearLeft = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4 * 3);
            aiMoi.AddAnimation("MoiWalkingRearLeft", saMoiWalkingRearLeft);
            lMoi = new Sprite("Moi", aiMoi) { Pivot = Vector2.One / 2, BringToFront = false };
            AddComponent(lMoi, Preferences.ViewportManager.MiddleCenterAnchor);
            #endregion Moi

            #region Game pad

            thumbStick = new ThumbStick();
            thumbStick.Pivot = new Vector2(0, 1);
            Vector2 margin = new Vector2(5, -5);
            AddComponent(thumbStick, Preferences.ViewportManager.BottomLeftAnchor + margin);

            Buttons buttons = new Buttons();
            margin = new Vector2(-5, -5) - buttons.Size;
            AddComponent(buttons, Preferences.ViewportManager.BottomRightAnchor + margin);
            #endregion Game pad
        }
    /// <summary>
    /// Play an animation
    /// </summary>
    /// <param name="p_animation">The index of the animation in the animations array</param>
    public void PlayAnimation(int p_animation)
    {
        if (m_currentanimation != StripAnimations[p_animation])
        {
            m_currentanimation = StripAnimations[p_animation];

            renderer.material.mainTexture = m_currentanimation.StripTexture;
            renderer.material.mainTextureScale = new Vector2(m_currentanimation.m_normalizedframesize, 1f);

            m_currentanimation.m_frame = 0;
            m_currentanimation.m_frameTimeout = m_currentanimation.PlaybackSpeed;

        }
    }
Exemple #4
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            random = new Random();

            SetBackground(ResourceManager.CreateImage(imagePath + "bg"), Adjustment.CENTER);

            //Rope
            rope = new Label(ResourceManager.CreateImage(imagePath + "rope"));
            rope.Released += new Component.ComponentEventHandler(rope_Released);
            rope.Draggable = false;
            rope.BringToFront = false;
            AddComponent(rope, 422, 384);

            //Doll
            doll = new Label(ResourceManager.CreateImage(imagePath + "doll"));
            doll.BringToFront = false;
            doll.Draggable = false;
            doll.Touchable = false;
            AddComponent(doll, 446, 223);

            //Ball
            AnimatedImage img = ResourceManager.CreateAnimatedImage(imagePath + "animated_ball");
            anim_ball = new StripAnimation(1505, 687, 215, 229, 19);
            anim_ball.FramesPerSecond = 40;
            anim_ball.IsLooped = false;
            img.AddAnimation("ball", anim_ball);
            ball = new Label(img);
            ball.BringToFront = false;
            ball.Released += new Component.ComponentEventHandler(ball_Released);
            AddComponent(ball, 252, 148);

            //Inked Balls
            orangeBall = new Label(ResourceManager.CreateImage(imagePath + "yellow_ball"));
            orangeBall.Released += new Component.ComponentEventHandler(Ball_Released);
            orangeBall.Draggable = false;
            AddComponent(orangeBall, -23, 125);

            blueBall = new Label(ResourceManager.CreateImage(imagePath + "blue_ball"));
            blueBall.Released += new Component.ComponentEventHandler(Ball_Released);
            blueBall.Draggable = false;
            AddComponent(blueBall, 77, 57);

            purpleBall = new Label(ResourceManager.CreateImage(imagePath + "purpel_ball"));
            purpleBall.Released += new Component.ComponentEventHandler(Ball_Released);
            purpleBall.Draggable = false;
            AddComponent(purpleBall, 0, 4);

            redBall = new Label(ResourceManager.CreateImage(imagePath + "red_ball"));
            redBall.Released += new Component.ComponentEventHandler(Ball_Released);
            redBall.Draggable = false;
            AddComponent(redBall, 8, 205);

            greenBall = new Label(ResourceManager.CreateImage(imagePath + "green_ball"));
            greenBall.Released += new Component.ComponentEventHandler(Ball_Released);
            greenBall.Draggable = false;
            AddComponent(greenBall, 50, 100);

            //Bird
            AnimatedImage pipin = ResourceManager.CreateAnimatedImage(imagePath + "animated_bird");
            anim_pipin = new StripAnimation(288, 106, 48, 106, 6);
            anim_pipin.IsLooped = false;
            anim_pipin.FramesPerSecond = 4;
            pipin.AddAnimation("bird", anim_pipin);
            lpipin = new Label(pipin);
            lpipin.Draggable = false;
            lpipin.Released += new Component.ComponentEventHandler(lpipin_Released);
            AddComponent(lpipin, 490, 42);

            //Train
            itrain_off = ResourceManager.CreateImage(imagePath + "train_off");
            itrain_on = ResourceManager.CreateImage(imagePath + "train_on");
            train = new Label(itrain_off);
            train.Released += new Component.ComponentEventHandler(train_Released);
            train.Draggable = false;
            AddComponent(train, 125, 314);

            //Animations
            //- > Ball
            aball = Animation.CreateAnimation(12);
            aball.AnimationType = AnimationType.Relative;
            int quakeoffset = 10;
            aball.AddKey(new KeyFrame(0, Vector2.Zero));
            aball.AddKey(new KeyFrame(3, new Vector2(-quakeoffset, 0)));
            aball.AddKey(new KeyFrame(6, new Vector2(quakeoffset, 0)));
            aball.AddKey(new KeyFrame(9, new Vector2(-quakeoffset, 0)));
            aball.AddKey(new KeyFrame(aball.NumFrames - 1, Vector2.Zero));
            AddAnimation(aball);

            //-> Train
            atrain = Animation.CreateAnimation(250);
            atrain.AnimationType = AnimationType.Relative;
            atrain.AddKey(new KeyFrame(0, Vector2.Zero, 0, 1, 1));
            atrain.AddKey(new KeyFrame(49, new Vector2( 320, 170), 0, 1.5f, 1));
            atrain.AddKey(new KeyFrame(50, new Vector2(-562, -213), 0, 0.8f, 1));
            atrain.AddKey(new KeyFrame(150, new Vector2(-562, -213), 0, 0.8f, 1));
            atrain.AddKey(new KeyFrame(atrain.NumFrames - 1, Vector2.Zero, 0, 1, 1));
            atrain.EndEvent += new Animation.AnimationHandler(atrain_EndEvent);
            AddAnimation(atrain);

            //-> Rope
            arope = Animation.CreateAnimation(75);
            arope.AnimationType = AnimationType.Relative;
            arope.AddKey(new KeyFrame(0, Vector2.Zero));
            arope.AddKey(new KeyFrame(10, new Vector2(-40, 0), true));
            arope.AddKey(new KeyFrame(arope.NumFrames - 1, Vector2.Zero));
            arope.KeyEvent += new Animation.AnimationHandler(arope_KeyEvent);
            AddAnimation(arope);

            //Initialize sound library
            AudioLibrary.Instance.Initialize();
        }