Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IEntity::get|setRorationOffset #228

Open
wants to merge 1 commit into
base: GLES2-AnchorCenter
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/org/andengine/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void call(final IEntity pEntity) {
protected float mHeight;

protected float mRotation = IEntity.ROTATION_DEFAULT;
protected float mRotationOffset = IEntity.ROTATION_OFFSET_DEFAULT;

protected float mRotationCenterX = IEntity.ROTATION_CENTER_X_DEFAULT;
protected float mRotationCenterY = IEntity.ROTATION_CENTER_Y_DEFAULT;
Expand Down Expand Up @@ -421,6 +422,16 @@ public void setRotation(final float pRotation) {
this.mParentToLocalTransformationDirty = true;
}

@Override
public float getRotationOffset() {
return this.mRotationOffset;
}

@Override
public void setRotationOffset(final float pRotationOffset) {
this.mRotationOffset = pRotationOffset;
}

@Override
public float getRotationCenterX() {
return this.mRotationCenterX;
Expand Down Expand Up @@ -1414,6 +1425,7 @@ public void reset() {
this.mChildrenVisible = true;
this.mChildrenIgnoreUpdate = false;

this.mRotationOffset = IEntity.ROTATION_OFFSET_DEFAULT;
this.mRotation = 0;
this.mScaleX = 1;
this.mScaleY = 1;
Expand Down Expand Up @@ -1550,7 +1562,7 @@ protected void applyTranslation(final GLState pGLState) {
}

protected void applyRotation(final GLState pGLState) {
final float rotation = this.mRotation;
final float rotation = this.mRotation + this.mRotationOffset;

if (rotation != 0) {
final float localRotationCenterX = this.mLocalRotationCenterX;
Expand Down
3 changes: 3 additions & 0 deletions src/org/andengine/entity/IEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public interface IEntity extends IDrawHandler, IUpdateHandler, IDisposable, ITou
public static final float OFFSET_CENTER_Y_DEFAULT = 0.5f;

public static final float ROTATION_DEFAULT = 0;
public static final float ROTATION_OFFSET_DEFAULT = 0;
public static final float ROTATION_CENTER_X_DEFAULT = 0.5f;
public static final float ROTATION_CENTER_Y_DEFAULT = 0.5f;

Expand Down Expand Up @@ -115,6 +116,8 @@ public interface IEntity extends IDrawHandler, IUpdateHandler, IDisposable, ITou
public boolean isRotated();
public float getRotation();
public void setRotation(final float pRotation);
public float getRotationOffset();
public void setRotationOffset(final float pRotationOffset);

public float getRotationCenterX();
public float getRotationCenterY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ public void setRotation(final float pRotation) {
this.mMenuItem.setRotation(pRotation);
}

@Override
public float getRotationOffset() {
return this.mMenuItem.getRotationOffset();
}

@Override
public void setRotationOffset(final float pRotation) {
this.mMenuItem.setRotationOffset(pRotation);
}

@Override
public float getRotationCenterX() {
return this.mMenuItem.getRotationCenterX();
Expand Down