本文整理汇总了Java中org.andengine.util.time.TimeConstants.NANOSECONDS_PER_SECOND属性的典型用法代码示例。如果您正苦于以下问题:Java TimeConstants.NANOSECONDS_PER_SECOND属性的具体用法?Java TimeConstants.NANOSECONDS_PER_SECOND怎么用?Java TimeConstants.NANOSECONDS_PER_SECOND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.andengine.util.time.TimeConstants
的用法示例。
在下文中一共展示了TimeConstants.NANOSECONDS_PER_SECOND属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onManagedUpdate
@Override
protected void onManagedUpdate(final float pSecondsElapsed) {
super.onManagedUpdate(pSecondsElapsed);
if (this.mAnimationRunning) {
final int loopCount = this.mAnimationData.getLoopCount();
final int[] frames = this.mAnimationData.getFrames();
final long animationDuration = this.mAnimationData.getAnimationDuration();
if (!this.mAnimationStartedFired && (this.mAnimationProgress == 0)) {
this.mAnimationStartedFired = true;
if (frames == null) {
this.setCurrentTileIndex(this.mAnimationData.getFirstFrameIndex());
} else {
this.setCurrentTileIndex(frames[0]);
}
this.mCurrentFrameIndex = 0;
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationStarted(this, loopCount);
this.mAnimationListener.onAnimationFrameChanged(this, AnimatedSprite.FRAMEINDEX_INVALID, 0);
}
}
final long nanoSecondsElapsed = (long) (pSecondsElapsed * TimeConstants.NANOSECONDS_PER_SECOND);
this.mAnimationProgress += nanoSecondsElapsed;
if (loopCount == IAnimationData.LOOP_CONTINUOUS) {
while (this.mAnimationProgress > animationDuration) {
this.mAnimationProgress -= animationDuration;
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationLoopFinished(this, this.mRemainingLoopCount, loopCount);
}
}
} else {
while (this.mAnimationProgress > animationDuration) {
this.mAnimationProgress -= animationDuration;
this.mRemainingLoopCount--;
if (this.mRemainingLoopCount < 0) {
break;
} else if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationLoopFinished(this, this.mRemainingLoopCount, loopCount);
}
}
}
if ((loopCount == IAnimationData.LOOP_CONTINUOUS) || (this.mRemainingLoopCount >= 0)) {
final int newFrameIndex = this.mAnimationData.calculateCurrentFrameIndex(this.mAnimationProgress);
if (this.mCurrentFrameIndex != newFrameIndex) {
if (frames == null) {
this.setCurrentTileIndex(this.mAnimationData.getFirstFrameIndex() + newFrameIndex);
} else {
this.setCurrentTileIndex(frames[newFrameIndex]);
}
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationFrameChanged(this, this.mCurrentFrameIndex, newFrameIndex);
}
}
this.mCurrentFrameIndex = newFrameIndex;
} else {
this.mAnimationRunning = false;
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationFinished(this);
}
}
}
}
示例2: FixedStepEngine
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
super(pEngineOptions);
this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
示例3: LimitedFPSEngine
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
super(pEngineOptions);
this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
示例4: onManagedUpdate
@Override
protected void onManagedUpdate(final float pSecondsElapsed) {
super.onManagedUpdate(pSecondsElapsed);
if(this.mAnimationRunning) {
final int loopCount = this.mAnimationData.getLoopCount();
final int[] frames = this.mAnimationData.getFrames();
final long animationDuration = this.mAnimationData.getAnimationDuration();
if(!this.mAnimationStartedFired && (this.mAnimationProgress == 0)) {
this.mAnimationStartedFired = true;
if(frames == null) {
this.setCurrentTileIndex(this.mAnimationData.getFirstFrameIndex());
} else {
this.setCurrentTileIndex(frames[0]);
}
this.mCurrentFrameIndex = 0;
if(this.mAnimationListener != null) {
this.mAnimationListener.onAnimationStarted(this, loopCount);
this.mAnimationListener.onAnimationFrameChanged(this, AnimatedSprite.FRAMEINDEX_INVALID, 0);
}
}
final long nanoSecondsElapsed = (long) (pSecondsElapsed * TimeConstants.NANOSECONDS_PER_SECOND);
this.mAnimationProgress += nanoSecondsElapsed;
if(loopCount == IAnimationData.LOOP_CONTINUOUS) {
while(this.mAnimationProgress > animationDuration ) {
this.mAnimationProgress -= animationDuration;
if(this.mAnimationListener != null) {
this.mAnimationListener.onAnimationLoopFinished(this, this.mRemainingLoopCount, loopCount);
}
}
} else {
while(this.mAnimationProgress > animationDuration) {
this.mAnimationProgress -= animationDuration;
this.mRemainingLoopCount--;
if(this.mRemainingLoopCount < 0) {
break;
} else if(this.mAnimationListener != null) {
this.mAnimationListener.onAnimationLoopFinished(this, this.mRemainingLoopCount, loopCount);
}
}
}
if((loopCount == IAnimationData.LOOP_CONTINUOUS) || (this.mRemainingLoopCount >= 0)) {
final int newFrameIndex = this.mAnimationData.calculateCurrentFrameIndex(this.mAnimationProgress);
if(this.mCurrentFrameIndex != newFrameIndex) {
if(frames == null) {
this.setCurrentTileIndex(this.mAnimationData.getFirstFrameIndex() + newFrameIndex);
} else {
this.setCurrentTileIndex(frames[newFrameIndex]);
}
if(this.mAnimationListener != null) {
this.mAnimationListener.onAnimationFrameChanged(this, this.mCurrentFrameIndex, newFrameIndex);
}
}
this.mCurrentFrameIndex = newFrameIndex;
} else {
this.mAnimationRunning = false;
if(this.mAnimationListener != null) {
this.mAnimationListener.onAnimationFinished(this);
}
}
}
}
示例5: FixedStepEngine
public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
super(pEngineOptions);
this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
示例6: LimitedFPSEngine
public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
super(pEngineOptions);
this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}