Java Code Examples for org.andengine.entity.IEntity#setRotation()

The following examples show how to use org.andengine.entity.IEntity#setRotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicsConnector.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdate(final float pSecondsElapsed) {
	final IEntity entity = this.mEntity;
	final Body body = this.mBody;

	if (this.mUpdatePosition) {
		final Vector2 position = body.getPosition();
		final float pixelToMeterRatio = this.mPixelToMeterRatio;
		entity.setPosition(position.x * pixelToMeterRatio, position.y * pixelToMeterRatio);
	}

	if (this.mUpdateRotation) {
		final float angle = body.getAngle();
		entity.setRotation(-MathUtils.radToDeg(angle));
	}
}
 
Example 2
Source File: PhysicsHandler.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
protected void onUpdate(final float pSecondsElapsed, final IEntity pEntity) {
	if (this.mEnabled) {
		/* Apply linear acceleration. */
		final float accelerationX = this.mAccelerationX;
		final float accelerationY = this.mAccelerationY;
		if (accelerationX != 0 || accelerationY != 0) {
			this.mVelocityX += accelerationX * pSecondsElapsed;
			this.mVelocityY += accelerationY * pSecondsElapsed;
		}

		/* Apply angular velocity. */
		final float angularVelocity = this.mAngularVelocity;
		if (angularVelocity != 0) {
			pEntity.setRotation(pEntity.getRotation() + angularVelocity * pSecondsElapsed);
		}

		/* Apply linear velocity. */
		final float velocityX = this.mVelocityX;
		final float velocityY = this.mVelocityY;
		if (velocityX != 0 || velocityY != 0) {
			pEntity.setPosition(pEntity.getX() + velocityX * pSecondsElapsed, pEntity.getY() + velocityY * pSecondsElapsed);
		}
	}
}
 
Example 3
Source File: PhysicsHandler.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
protected void onUpdate(final float pSecondsElapsed, final IEntity pEntity) {
	if(this.mEnabled) {
		/* Apply linear acceleration. */
		final float accelerationX = this.mAccelerationX;
		final float accelerationY = this.mAccelerationY;
		if(accelerationX != 0 || accelerationY != 0) {
			this.mVelocityX += accelerationX * pSecondsElapsed;
			this.mVelocityY += accelerationY * pSecondsElapsed;
		}

		/* Apply angular velocity. */
		final float angularVelocity = this.mAngularVelocity;
		if(angularVelocity != 0) {
			pEntity.setRotation(pEntity.getRotation() + angularVelocity * pSecondsElapsed);
		}

		/* Apply linear velocity. */
		final float velocityX = this.mVelocityX;
		final float velocityY = this.mVelocityY;
		if(velocityX != 0 || velocityY != 0) {
			pEntity.setPosition(pEntity.getX() + velocityX * pSecondsElapsed, pEntity.getY() + velocityY * pSecondsElapsed);
		}
	}
}
 
Example 4
Source File: RotationModifier.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
protected void onSetInitialValue(final IEntity pEntity, final float pRotation) {
	pEntity.setRotation(pRotation);
}
 
Example 5
Source File: RotationModifier.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pRotation) {
	pEntity.setRotation(pRotation);
}
 
Example 6
Source File: RotationByModifier.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
protected void onChangeValue(final float pSecondsElapsed, final IEntity pEntity, final float pRotation) {
	pEntity.setRotation(pEntity.getRotation() + pRotation);
}
 
Example 7
Source File: RotationModifier.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
protected void onSetInitialValue(final IEntity pEntity, final float pRotation) {
	pEntity.setRotation(pRotation);
}
 
Example 8
Source File: RotationModifier.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pRotation) {
	pEntity.setRotation(pRotation);
}
 
Example 9
Source File: RotationByModifier.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
protected void onChangeValue(final float pSecondsElapsed, final IEntity pEntity, final float pRotation) {
	pEntity.setRotation(pEntity.getRotation() + pRotation);
}