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


C# Image.UpdateSourceRectPosition方法代碼示例

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


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

示例1: LoadButtons

        void LoadButtons()
        {
            addToSongBook = new DialogButton(!currentSongism.Discovered);
            cancel = new DialogButton(true);

            Image addImage = new Image();
            addImage.Path = "Gameplay/UI/buttonsheet";
            addImage.Effects = "SpriteSheetEffect";
            addImage.FontName = "Fonts/GameFont_Size32";
            addImage.TextAnimationTravel = new Vector2(0, 9);
            addImage.TextAlignment = Globals.TextAlignment.Center;
            if (currentSongism.Discovered)
                addImage.TextColor = Color.Gray;

            addImage.LoadContent();

            Image cancelImage = new Image();
            cancelImage.Path = "Gameplay/UI/buttonsheet";
            cancelImage.Effects = "SpriteSheetEffect";
            cancelImage.FontName = "Fonts/GameFont_Size32";
            cancelImage.TextAnimationTravel = new Vector2(0, 9);
            cancelImage.TextAlignment = Globals.TextAlignment.Center;

            cancelImage.LoadContent();

            addToSongBook.ButtonName = "Add";
            addToSongBook.Image = addImage;
            //addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width / 2),
            //    (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SourceRect.Height));
            //addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width),
            //    (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SourceRect.Height));

            addImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
            addImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
            addImage.UpdateSourceRectPosition ((int)addImage.Position.X, (int)addImage.Position.Y);

            //addToSongBook.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (addImage.SourceRect.Width),
            //    (ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SpriteSheetEffect.FrameHeight - 16));
            addToSongBook.Image.Position = new Vector2(CurrentSongismImage.Position.X - addImage.SpriteSheetEffect.FrameWidth + 16,
                ScreenManager.Instance.GraphicsDevice.Viewport.Height - addImage.SpriteSheetEffect.FrameHeight - 16);

            addImage.AddText("Add");

            cancel.ButtonName = "Cancel";
            cancel.Image = cancelImage;
            //cancel.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - cancelImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
            //    (ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SourceRect.Height));

            cancelImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
            cancelImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
            cancelImage.UpdateSourceRectPosition ((int)cancelImage.Position.X, (int)cancelImage.Position.Y);

            //cancel.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - cancelImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
            //    (ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SpriteSheetEffect.FrameHeight - 16));
            cancel.Image.Position = new Vector2(CurrentSongismImage.Position.X + (CurrentSongismImage.SourceRect.Width / 2) + 16,
                ScreenManager.Instance.GraphicsDevice.Viewport.Height - cancelImage.SpriteSheetEffect.FrameHeight - 16);

            cancelImage.AddText("Cancel");

            addToSongBook.OnButtonRelease += addToSongBook_OnButtonRelease;
            cancel.OnButtonRelease += cancel_OnButtonRelease;
        }
開發者ID:nkruger311,項目名稱:SongAdventureAndroid,代碼行數:62,代碼來源:SongismScreen.cs

示例2: LoadButtons

        void LoadButtons()
        {
            _btnNewGame = new DialogButton(true);
            _btnLoadGame = new DialogButton(CheckForExistingGameFiles());

            Image newGameImage = new Image();
            newGameImage.Path = "Gameplay/UI/buttonsheet";
            newGameImage.Effects = "SpriteSheetEffect";
            newGameImage.FontName = "Fonts/GameFont_Size32";
            newGameImage.TextAnimationTravel = new Vector2(0, 9);
            newGameImage.TextAlignment = Globals.TextAlignment.Center;

            newGameImage.LoadContent();

            Image loadGameImage = new Image();
            loadGameImage.Path = "Gameplay/UI/buttonsheet";
            loadGameImage.Effects = "SpriteSheetEffect";
            loadGameImage.FontName = "Fonts/GameFont_Size32";
            loadGameImage.TextAnimationTravel = new Vector2(0, 9);
            loadGameImage.TextAlignment = Globals.TextAlignment.Center;

            if (!CheckForExistingGameFiles())
                loadGameImage.TextColor = Color.Gray;

            loadGameImage.LoadContent();

            _btnNewGame.ButtonName = "_btnNewGame";
            _btnNewGame.Image = newGameImage;

            newGameImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
            newGameImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
            newGameImage.UpdateSourceRectPosition ((int)newGameImage.Position.X, (int)newGameImage.Position.Y);

            _btnNewGame.Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (newGameImage.SourceRect.Width),
                (ScreenManager.Instance.GraphicsDevice.Viewport.Height / 2) - newGameImage.SpriteSheetEffect.FrameHeight);

            newGameImage.AddText("New Game");

            _btnLoadGame.ButtonName = "_btnLoadGame";
            _btnLoadGame.Image = loadGameImage;

            loadGameImage.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
            loadGameImage.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
            loadGameImage.UpdateSourceRectPosition ((int)loadGameImage.Position.X, (int)loadGameImage.Position.Y);

            _btnLoadGame.Image.Position = new Vector2((ScreenManager.Instance.GraphicsDevice.Viewport.Width - loadGameImage.SourceRect.Width) - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 25),
                (ScreenManager.Instance.GraphicsDevice.Viewport.Height - loadGameImage.SpriteSheetEffect.FrameHeight - 16));

            _btnLoadGame.Image.Position = new Vector2 ((ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2) - (newGameImage.SourceRect.Width),
                (_btnNewGame.Image.Position.Y + loadGameImage.SpriteSheetEffect.FrameHeight + 50));

            loadGameImage.AddText("Load Game");

            _btnNewGame.OnButtonRelease += _btnNewGame_OnButtonRelease;
            _btnLoadGame.OnButtonRelease += _btnLoadGame_OnButtonRelease;
        }
開發者ID:nkruger311,項目名稱:SongAdventureAndroid,代碼行數:56,代碼來源:TitleScreen.cs

示例3: LoadContent

        public void LoadContent()
        {
            IsInitializing = true;

            RadioButton = new Image();
            RadioButton.Path = "Gameplay/UI/radiobuttonsheet";
            RadioButton.SourceRect = new Rectangle(0, 0, 36, 36);

            RadioButton.Effects = "SpriteSheetEffect";

            RadioButton.LoadContent();
            RadioButton.DeactivateEffect("FadeEffect");
            RadioButton.Alpha = 1.0f;
            RadioButton.SpriteSheetEffect.AmountOfFrames = new Vector2(1, 2);
            RadioButton.SpriteSheetEffect.CurrentFrame = new Vector2(0, 0);
            RadioButton.Position = Position;
            RadioButton.UpdateSourceRectPosition ((int)RadioButton.Position.X, (int)RadioButton.Position.Y);

            font = ScreenManager.Instance.Content.Load<SpriteFont> ("Fonts/GameFont_Size32");

            _radioButtonBoundingBox = new Rectangle(RadioButton.SourceRect.X, RadioButton.SourceRect.Y, RadioButton.SourceRect.Width, RadioButton.SourceRect.Height);
            _songNameBoundingBox = new Rectangle((int)RadioButton.Position.X + RadioButton.SpriteSheetEffect.FrameWidth + 10, (int)Position.Y - 10, (int)font.MeasureString(SongName).X, (int)font.MeasureString(SongName).Y);

            Loaded = true;
            IsInitializing = false;
        }
開發者ID:nkruger311,項目名稱:SongAdventureAndroid,代碼行數:26,代碼來源:SongismGuessingItem.cs


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