2016-11-19 8 views
0

wizardPos変数が画面の中央に表示されているときにスプライト描画が左上に描画されるのはなぜですか?スプライトバッチ描画が間違った位置にある

//in load content 
wizardPos = new Vector2(graphics.PreferredBackBufferWidth /2, 700); 
wizardChar = new Characters.Wizard(this, spriteBatch, wizardPos, wizardWalk1); 


//in Draw method 

this.spriteBatch.Draw(tempWizard, wizardPos, null, Color.White, 0f, wizardPos, 1f, SpriteEffects.None, 0f); 

Wizard should be drawing in red rectangle

答えて

1

この試してみてください:あなたのスプライトのpositionが実際にあなたのスプライトのoriginの位置である

this.spriteBatch.Draw(tempWizard, wizardPos, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); 

を。したがって、originwizardPosに設定すると、画面ではなくoriginがスプライトに対して相対的に設定されます。したがって、originpositionを同じ値に設定すると、効果的に相殺されます。回転のようなものだけでなく

+0

はあなたにBENOに感謝を計算するのに使用されているので

originは通常、スプライトの境界内のどこかになります!完璧に働いた。どのように起源が正確に働いたのか分かりませんでした。感謝します。 –

関連する問題