All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codingame.gameengine.module.entities.SpriteBasedEntity Maven / Gradle / Ivy

package com.codingame.gameengine.module.entities;

/**
 * A Sprite is a graphical entity which displays an image. That image must be loaded into the viewer's texture cache, which you can configure by
 * adding files to the assets folder of your game's project.
 */
public abstract class SpriteBasedEntity> extends TextureBasedEntity implements Mask {

    private String image;
    private Integer baseWidth, baseHeight;
    private ScaleMode scaleMode = ScaleMode.LINEAR;

    /**
     * Sets the image for this Sprite.
     * 

* You must either: *

    *
  • use the filename of an image relative to the assets folder of the Java project. *
  • use the a player's nickname token. *
* * @param image * the name of the image to use for this Sprite. * @return this Sprite. */ public T setImage(String image) { this.image = image; set("image", image, null); return self(); } /** * Sets the image base width for this Sprite. If not set, the image base width is the real image width. * * @param baseWidth * image width * @return this Sprite. */ public T setBaseWidth(int baseWidth) { this.baseWidth = baseWidth; set("baseWidth", baseWidth, null); return self(); } /** * Sets the image base height for this Sprite. If not set, the image base height is the real image height. * * @param baseHeight * image height * @return this Sprite. */ public T setBaseHeight(int baseHeight) { this.baseHeight = baseHeight; set("baseHeight", baseHeight, null); return self(); } /** * Returns the name of the image used for this Sprite. *

* Can be a player's nickname token. * * @return the name of the image used for this Sprite */ public String getImage() { return image; } /** * Returns the image base width for this Sprite. If not set, the image base width is the real image width, but this will return null. * * @return the image base width for this Sprite. */ public Integer getBaseWidth() { return baseWidth; } /** * Returns the image base height for this Sprite. If not set, the image base height is the real image height, but this will return * null. * * @return the image base height for this Sprite. */ public Integer getBaseHeight() { return baseHeight; } /** * Sets the scale mode of this TextureBasedEntity. * * @param scaleMode * the scale mode of this TextureBasedEntity. * @return this TextureBasedEntity. */ public T setScaleMode(ScaleMode scaleMode) { this.scaleMode = scaleMode; set("scaleMode", scaleMode); return self(); } /** * Returns the scale mode of this TextureBasedEntity. *

* Default is LINEAR. * * @return the scale mode of this TextureBasedEntity. */ public ScaleMode getScaleMode() { return scaleMode; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy