「MonoGame (Xamarin.Android)で初期解像度がおかしい機種の対策」の版間の差分
Administrator (トーク | 投稿記録) 編集の要約なし |
Administrator (トーク | 投稿記録) 編集の要約なし |
||
| 3行目: | 3行目: | ||
そのような場合は初期化の際に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> | ||
2020年9月15日 (火) 05:40時点における版
一部のAndroid端末でMonoGameを使ったアプリを起動すると、解像度の初期値がおかしく、右側や上側に余白ができてしまう現象が発生する。 この現象は主に「ADBコマンドでAndroid端末の解像度を変更する」で解像度を変更している場合に発生する模様。 そのような場合は初期化の際にGraphicsDevice.DisplayModeプロパティの値で明示的に解像度を設定すると改善する。
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();
}