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


Java SequenceModifier类代码示例

本文整理汇总了Java中org.andengine.util.modifier.SequenceModifier的典型用法代码示例。如果您正苦于以下问题:Java SequenceModifier类的具体用法?Java SequenceModifier怎么用?Java SequenceModifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SequenceModifier类属于org.andengine.util.modifier包,在下文中一共展示了SequenceModifier类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PathModifier

import org.andengine.util.modifier.SequenceModifier; //导入依赖的package包/类
public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener, final IPathModifierListener pPathModifierListener, final IEaseFunction pEaseFunction) throws IllegalArgumentException {
	super(pEntityModiferListener);
	final int pathSize = pPath.getSize();

	if (pathSize < 2) {
		throw new IllegalArgumentException("Path needs at least 2 waypoints!");
	}

	this.mPath = pPath;
	this.mPathModifierListener = pPathModifierListener;

	final MoveModifier[] moveModifiers = new MoveModifier[pathSize - 1];

	final float[] coordinatesX = pPath.getCoordinatesX();
	final float[] coordinatesY = pPath.getCoordinatesY();

	final float velocity = pPath.getLength() / pDuration;

	final int modifierCount = moveModifiers.length;
	for (int i = 0; i < modifierCount; i++) {
		final float duration = pPath.getSegmentLength(i) / velocity;
		moveModifiers[i] = new MoveModifier(duration, coordinatesX[i], coordinatesY[i], coordinatesX[i + 1], coordinatesY[i + 1], null, pEaseFunction);
	}

	/* Create a new SequenceModifier and register the listeners that
	 * call through to mEntityModifierListener and mPathModifierListener. */
	this.mSequenceModifier = new SequenceModifier<IEntity>(
			new ISubSequenceModifierListener<IEntity>() {
				@Override
				public void onSubSequenceStarted(final IModifier<IEntity> pModifier, final IEntity pEntity, final int pIndex) {
					if (PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathWaypointStarted(PathModifier.this, pEntity, pIndex);
					}
				}

				@Override
				public void onSubSequenceFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity, final int pIndex) {
					if (PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathWaypointFinished(PathModifier.this, pEntity, pIndex);
					}
				}
			},
			new IEntityModifierListener() {
				@Override
				public void onModifierStarted(final IModifier<IEntity> pModifier, final IEntity pEntity) {
					PathModifier.this.onModifierStarted(pEntity);
					if (PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathStarted(PathModifier.this, pEntity);
					}
				}

				@Override
				public void onModifierFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity) {
					PathModifier.this.onModifierFinished(pEntity);
					if (PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathFinished(PathModifier.this, pEntity);
					}
				}
			},
			moveModifiers
	);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:63,代码来源:PathModifier.java

示例2: PathModifier

import org.andengine.util.modifier.SequenceModifier; //导入依赖的package包/类
public PathModifier(final float pDuration, final Path pPath, final IEntityModifierListener pEntityModiferListener, final IPathModifierListener pPathModifierListener, final IEaseFunction pEaseFunction) throws IllegalArgumentException {
	super(pEntityModiferListener);
	final int pathSize = pPath.getSize();

	if (pathSize < 2) {
		throw new IllegalArgumentException("Path needs at least 2 waypoints!");
	}

	this.mPath = pPath;
	this.mPathModifierListener = pPathModifierListener;

	final MoveModifier[] moveModifiers = new MoveModifier[pathSize - 1];

	final float[] coordinatesX = pPath.getCoordinatesX();
	final float[] coordinatesY = pPath.getCoordinatesY();

	final float velocity = pPath.getLength() / pDuration;

	final int modifierCount = moveModifiers.length;
	for(int i = 0; i < modifierCount; i++) {
		final float duration = pPath.getSegmentLength(i) / velocity;
		moveModifiers[i] = new MoveModifier(duration, coordinatesX[i], coordinatesX[i + 1], coordinatesY[i], coordinatesY[i + 1], null, pEaseFunction);
	}

	/* Create a new SequenceModifier and register the listeners that
	 * call through to mEntityModifierListener and mPathModifierListener. */
	this.mSequenceModifier = new SequenceModifier<IEntity>(
			new ISubSequenceModifierListener<IEntity>() {
				@Override
				public void onSubSequenceStarted(final IModifier<IEntity> pModifier, final IEntity pEntity, final int pIndex) {
					if(PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathWaypointStarted(PathModifier.this, pEntity, pIndex);
					}
				}

				@Override
				public void onSubSequenceFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity, final int pIndex) {
					if(PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathWaypointFinished(PathModifier.this, pEntity, pIndex);
					}
				}
			},
			new IEntityModifierListener() {
				@Override
				public void onModifierStarted(final IModifier<IEntity> pModifier, final IEntity pEntity) {
					PathModifier.this.onModifierStarted(pEntity);
					if(PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathStarted(PathModifier.this, pEntity);
					}
				}

				@Override
				public void onModifierFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity) {
					PathModifier.this.onModifierFinished(pEntity);
					if(PathModifier.this.mPathModifierListener != null) {
						PathModifier.this.mPathModifierListener.onPathFinished(PathModifier.this, pEntity);
					}
				}
			},
			moveModifiers
	);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:63,代码来源:PathModifier.java


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