BaseSprite.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:TH902 作者:
/**
 * @param color
 *            0 - blue; 1 - red; 2 - green; 3 - yellow
 */
public static Entity Create(Vector2 position, int color, int maxhp, Component... Ves) {
    if (color < 0 || color > 3) {
        throw new IllegalArgumentException("Color of the enemy (sprite) should be between 0 and 3!");
    }
    Entity entity = Entity.Create();
    Transform transform = new Transform(position, new Vector2(0.5f, 0.5f));
    entity.AddComponent(transform);
    BaseSprite component = new BaseSprite();
    component.selfColor = color;
    component.animation = new AnimationDrawable();
    if (texture != ResourceManager.enemies.get(0)) {
        texture = ResourceManager.enemies.get(0);
        regions = TextureRegion.split(texture, texture.getWidth() / 12, texture.getHeight() / 4);
    }
    component.animation.setAnimation(new Animation<TextureRegion>(1, regions[color]));
    EnemyHP hp = new EnemyHP(maxhp);
    entity.AddComponent(hp);
    entity.AddComponent(new EnemyJudgeCircle(48 * transform.scale.x, hp));
    entity.AddComponent(new EnemyChaseable(hp));
    entity.AddComponent(component);
    for (Component tmpc : Ves) {
        entity.AddComponent(tmpc);
    }
    return entity;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号