當前位置: 首頁>>代碼示例>>C#>>正文


C# Animation.AddKey方法代碼示例

本文整理匯總了C#中Animation.AddKey方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.AddKey方法的具體用法?C# Animation.AddKey怎麽用?C# Animation.AddKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Animation的用法示例。


在下文中一共展示了Animation.AddKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

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

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

            lbl = new Label(ResourceManager.CreateImage("cell_car"));
            AddComponent(lbl, Preferences.Width / 2, Preferences.Height / 2);

            anim = Animation.CreateAnimation(20);

            anim.AnimationType = AnimationType.Relative;
            anim.AddKey(new KeyFrame(0, 0.1f));
            anim.AddKey(new KeyFrame(5, 0.5f));
            anim.AddKey(new KeyFrame(10, 0.9f));
            anim.AddKey(new KeyFrame(15, 0.5f));
            anim.AddKey(new KeyFrame(anim.NumFrames - 1, 0.1f));

            anim.IsLooped = true;

            AddAnimation(anim);
            //  anim.Play(lbl);

            anim.KeyEvent += new Animation.AnimationHandler(anim_KeyEvent);
            playStop = new Button("Play/Stop");
            AddComponent(playStop, 100, 200);
            playStop.Released += new Component.ComponentEventHandler(playStop_Released);

            keyEventLabel = new Label("Event Raised!!");
            AddComponent(keyEventLabel, Preferences.Width / 2, 620);
            keyEventLabel.Visible = false;
        }
開發者ID:Syderis,項目名稱:CellSDK-Tutorials,代碼行數:35,代碼來源:MainScreen.cs

示例2: Initialize

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

            // Background
            SetBackground(ResourceManager.CreateImage("Images/background_ios"), Screen.Adjustment.CENTER);

            // Sprite sheet image
            SpriteSheet iSpriteSheet = ResourceManager.CreateSpriteSheet("Images/PigeonsAttackSpriteSheet");

            // Pigeons
            Sprite[] lPigeons = new Sprite[5];
            Image iPigeonLookingAtLeft = iSpriteSheet["pigeon_1"];
            Image iPigeonLookingAtRight = iSpriteSheet["pigeon_2"];
            random = new Random();

            lPigeons[0] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[1] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[2] = new Sprite("pigeon", iPigeonLookingAtRight);
            lPigeons[3] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[4] = new Sprite("pigeon", iPigeonLookingAtRight);

            AddComponent(lPigeons[0], 79, 12);
            AddComponent(lPigeons[1], 207, 15);
            AddComponent(lPigeons[2], 345, 16);
            AddComponent(lPigeons[3], 495, 16);
            AddComponent(lPigeons[4], 634, 7);

            // Car
            cCar = new Sprite("cCar", Image.CreateImage(Color.Transparent, 238, 164));

            // Car itself
            lCar = new Sprite("car", iSpriteSheet["car"]);
            cCar.AddChild(lCar);

            // Tires
            Image iTire = iSpriteSheet["steel"];
            lLeftTire = new Sprite("lLeftTire", iTire) { Position = new Vector2(70, 138), Pivot = Vector2.One / 2};
            cCar.AddChild(lLeftTire);

            lRightTire = new Sprite("lRightTire", iTire) { Position = new Vector2(162, 138), Pivot = Vector2.One / 2 };
            cCar.AddChild(lRightTire);

            AddComponent(cCar, 11, 480 - 164 - 24);

            if (AccelerometerSensor.Instance.IsConnected)
            {
                accelerometerDetected = true;
                AccelerometerSensor.Instance.Start();
            }

            #region Shits
            Image iShit = iSpriteSheet["shit"];
            lShit = new Sprite("shit", iShit) { Pivot = Vector2.One / 2};
            // The shit will be hidden since the very begining, so doesn't matter where to place it
            AddComponent(lShit, -100, -100);
            lShit.Visible = false;

            shitPositions = new Vector2[5];
            shitPositions[0] = new Vector2(135, 63);
            shitPositions[1] = new Vector2(267, 70);
            shitPositions[2] = new Vector2(367, 70);
            shitPositions[3] = new Vector2(553, 70);
            shitPositions[4] = new Vector2(657, 63);

            elapsedTimeBetweenShits = TimeSpan.Zero;

            // 60 will cause the animation to take 1 s to complete
            aShitFalling = Animation.CreateAnimation(75);
            aShitFalling.AnimationType = AnimationType.Relative;
            aShitFalling.AddKey(new KeyFrame(0, Vector2.Zero));
            aShitFalling.AddKey(new KeyFrame(aShitFalling.NumFrames - 1, new Vector2(0, 400)));
            // Once the shit touches the road it must dissapear
            aShitFalling.EndEvent += delegate { lShit.Visible = false; };
            AddAnimation(aShitFalling);
            #endregion Shits

            // Semaphore lights
            lRed = new Sprite("red", iSpriteSheet["red"]);
            AddComponent(lRed, 716, 187);
            lAmber = new Sprite("amber", iSpriteSheet["amber"]);
            AddComponent(lAmber, 715, 215);
            lGreen = new Sprite("green", iSpriteSheet["green"]);
            AddComponent(lGreen, 717, 241);
            lAmber.Visible = lGreen.Visible = false;

            // This var will hold the playing time
            elapsedGameTime = TimeSpan.Zero;

            #if DEBUG
            lLog = new Label("N/A", Color.Black, Color.White);
            AddComponent(lLog, Preferences.ViewportManager.TopLeftAnchor);
            #endif

            impacts = 0;
            minClamp = 11;
            // The car won't overpass the semaphore until it turns green
//.........這裏部分代碼省略.........
開發者ID:Syderis,項目名稱:CellSDK-Samples,代碼行數:101,代碼來源:MainScreen.cs


注:本文中的Animation.AddKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。