当我开始我的应用程序时,对象在给定位置(给定矢量)产生。但是,当我将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