C# 클래스 Nez.SubpixelFloat

simple helper class that manages a float value. It stores the value until the total accumulated is greater than 1. Once it exceeds 1 the value will be added on to amount when update is called. General usage would be something like the following. - calculate your objects velocity however you normally would - multiply by deltaTime to keep it framerate independent - pass the calculated delta movement for this frame to the SubpixelFloat.update method for both x and y. This will result in deltaMove being rounded to an int and the SubpixelFloat will deal with accumulating the excess value. var deltaMove = velocity * Time.deltaTime; _x.update( ref deltaMove.X ); _y.update( ref deltaMove.Y );
파일 보기 프로젝트 열기: prime31/Nez

공개 프로퍼티들

프로퍼티 타입 설명
remainder float

공개 메소드들

메소드 설명
reset ( ) : void

resets the remainder to 0. Useful when an object collides with an immovable object. In that case you will want to zero out the subpixel remainder since it is null and void due to the collision.

update ( float &amount ) : void

increments remainder by amount, truncates the value to an int, stores off the new remainder and sets amount to the current value.

메소드 상세

reset() 공개 메소드

resets the remainder to 0. Useful when an object collides with an immovable object. In that case you will want to zero out the subpixel remainder since it is null and void due to the collision.
public reset ( ) : void
리턴 void

update() 공개 메소드

increments remainder by amount, truncates the value to an int, stores off the new remainder and sets amount to the current value.
public update ( float &amount ) : void
amount float Amount.
리턴 void

프로퍼티 상세

remainder 공개적으로 프로퍼티

public float remainder
리턴 float