「MonoGame (Xamarin.Android)で初期解像度がおかしい機種の対策」の版間の差分
imported>Administrator 編集の要約なし |
Administrator (トーク | 投稿記録) 編集の要約なし |
||
| (同じ利用者による、間の2版が非表示) | |||
| 1行目: | 1行目: | ||
一部の[[Android]]端末で[[MonoGame]]を使ったアプリを起動すると、解像度の初期値がおかしく、右側や上側に余白ができてしまう現象が発生する。 | |||
この現象は主に「[[ADBコマンドでAndroid端末の解像度を変更する]]」で解像度を変更している場合に発生する模様。 | この現象は主に「[[ADBコマンドでAndroid端末の解像度を変更する]]」で解像度を変更している場合に発生する模様。 | ||
そのような場合は初期化の際にGraphicsDevice.DisplayModeプロパティの値で明示的に解像度を設定すると改善する。 | そのような場合は初期化の際にGraphicsDevice.DisplayModeプロパティの値で明示的に解像度を設定すると改善する。 | ||
<source lang="csharp"> | <source lang="csharp"> | ||
protected override void Initialize() | |||
{ | |||
this.graphics.IsFullScreen = false; | |||
this.graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; | |||
this.graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; | |||
this.graphics.ApplyChanges(); | |||
base.Initialize(); | |||
} | |||
</source> | </source> | ||