com.codingame.gameengine.module.entities.TextureBasedEntity Maven / Gradle / Ivy
package com.codingame.gameengine.module.entities;
/**
* Any PIXI Entity based on a texture shares the properties found in this TextureBasedEntity
.
*
* @param
* a subclass inheriting Entity, used in order to return this as a T instead of a TextureBasedEntity
.
*/
public abstract class TextureBasedEntity> extends BlendableEntity {
private double anchorX = 0, anchorY = 0;
private int tint = 0xFFFFFF;
TextureBasedEntity() {
super();
}
/**
* Sets both the X and Y anchors of this TextureBasedEntity
as a percentage of its width and height.
*
* The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
*
* @param anchor
* the percentage for both anchors of this TextureBasedEntity
.
* @return this TextureBasedEntity
.
*/
public T setAnchor(double anchor) {
setAnchorX(anchor);
setAnchorY(anchor);
return self();
}
/**
* Returns the X anchor of this TextureBasedEntity
as a percentage of its width.
*
* Default is 0.
*
* @return the X anchor of this TextureBasedEntity
as a percentage of its width.
*/
public double getAnchorX() {
return anchorX;
}
/**
* Sets the X anchor of this TextureBasedEntity
as a percentage of its width.
*
* The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
*
* @param anchorX
* the X anchor for this TextureBasedEntity
.
* @return this TextureBasedEntity
.
*/
public T setAnchorX(double anchorX) {
return setAnchorX(anchorX, null);
}
/**
* Sets the X anchor of this TextureBasedEntity
as a percentage of its width.
*
* The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
*
* @param anchorX
* the X anchor for this TextureBasedEntity
.
* @param curve
* the transition to animate between values of this property.
* @return this TextureBasedEntity
.
*/
public T setAnchorX(double anchorX, Curve curve) {
this.anchorX = anchorX;
set("anchorX", anchorX, curve);
return self();
}
/**
* Returns the Y anchor of this TextureBasedEntity
as a percentage of its width.
*
* Default is 0.
*
* @return the Y anchor of this TextureBasedEntity
as a percentage of its width.
*/
public double getAnchorY() {
return anchorY;
}
/**
* Sets the Y anchor of this TextureBasedEntity
as a percentage of its width.
*
* The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
*
* @param anchorY
* the Y anchor for this TextureBasedEntity
.
* @return this TextureBasedEntity
.
*/
public T setAnchorY(double anchorY) {
return setAnchorY(anchorY, null);
}
/**
* Sets the Y anchor of this TextureBasedEntity
as a percentage of its width.
*
* The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
*
* @param anchorY
* the Y anchor for this TextureBasedEntity
.
* @param curve
* the transition to animate between values of this property.
* @return this TextureBasedEntity
.
*/
public T setAnchorY(double anchorY, Curve curve) {
this.anchorY = anchorY;
set("anchorY", anchorY, curve);
return self();
}
/**
* Sets the tint of this TextureBasedEntity
as an RGB integer.
*
* @param color
* the tint of this TextureBasedEntity
.
* @return this TextureBasedEntity
.
* @exception IllegalArgumentException
* if color is not a valid RGB integer.
*/
public T setTint(int color) {
return setTint(color, null);
}
/**
* Sets the tint of this TextureBasedEntity
as an RGB integer.
*
* @param color
* the tint of this TextureBasedEntity
.
* @param curve
* the transition to animate between values of this property.
* @return this TextureBasedEntity
.
* @exception IllegalArgumentException
* if color is not a valid RGB integer.
*/
public T setTint(int color, Curve curve) {
requireValidColor(color);
this.tint = color;
set("tint", color, curve);
return self();
}
/**
* Returns the tint of this TextureBasedEntity
as an RGB integer.
*
* Default is 0xFFFFFF (white)
*
* @return the tint of this TextureBasedEntity
.
*/
public int getTint() {
return tint;
}
}