當我開始我的應用程序時,對象在給定位置(給定矢量)產生。但是,當我將monogame窗口最小化並重新打開它時,則該對象位於左上角。當最小化時位置重置
這究竟是爲什麼?
注:這是我Draw
方法:
如何起始位置的計算方法:
// Vector2 position is the starting position for the object
public PlayerMovement(Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffSet, Point currentFrame, Point startFrame, Point sheetSize, float speed, float speedMultiplier, float millisecondsPerFrame)
: base(textureImage, position, frameSize, collisionOffSet, currentFrame, startFrame, sheetSize, speed, speedMultiplier, millisecondsPerFrame)
{
children = new List<Sprite>();
}
我用Vector2 direction
知道精靈面對的方向:
public abstract Vector2 direction
{
get;
}
我在我的中使用類和返回inputDirection * speed
(inputDirection
是Vector2
)
最後,在我的Update
方法,我做position += direction
,我也檢查,如果玩家沒有觸摸屏的邊界(他不能動出屏幕)。
如何設置currentFrame和frameSize計算? –
'currentFrame'是動畫中的當前幀。我爲遊戲在動畫中顯示下一個精靈時等待的時間分配了一個變量。 「frameSize」是動畫中一個精靈的大小(高度和像素有多少像素)。但這不是我想的問題,因爲動畫效果很好。 – Jelle
我在主遊戲類中檢查「IsActive」嗎? – Jelle