当前位置: 首页>>代码示例>>Java>>正文


Java TimeConstants.NANOSECONDS_PER_SECOND属性代码示例

本文整理汇总了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);
			}
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:66,代码来源:AnimatedSprite.java

示例2: FixedStepEngine

public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
	super(pEngineOptions);

	this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:5,代码来源:FixedStepEngine.java

示例3: LimitedFPSEngine

public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
	super(pEngineOptions);

	this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:5,代码来源:LimitedFPSEngine.java

示例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);
			}
		}
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:66,代码来源:AnimatedSprite.java

示例5: FixedStepEngine

public FixedStepEngine(final EngineOptions pEngineOptions, final int pStepsPerSecond) {
	super(pEngineOptions);
	this.mStepLength = TimeConstants.NANOSECONDS_PER_SECOND / pStepsPerSecond;
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:4,代码来源:FixedStepEngine.java

示例6: LimitedFPSEngine

public LimitedFPSEngine(final EngineOptions pEngineOptions, final int pFramesPerSecond) {
	super(pEngineOptions);
	this.mPreferredFrameLengthNanoseconds = TimeConstants.NANOSECONDS_PER_SECOND / pFramesPerSecond;
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:4,代码来源:LimitedFPSEngine.java


注:本文中的org.andengine.util.time.TimeConstants.NANOSECONDS_PER_SECOND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。