java类com.badlogic.gdx.graphics.g2d.Sprite的实例源码

TowerPlacementSystem.java 文件源码 项目:ExamensArbeteTD 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected void processEntity(Entity entity, float deltaTime) {

    if (_tile != null) {
        _batch.begin();
        TextureRegion textureRegion = _tile.getCell().getTile().getTextureRegion();
        Sprite sprite = new Sprite(textureRegion);

        if (!isLegalPlacement()) {
            sprite.setColor(Color.RED);
            sprite.setAlpha(0.5f);
        } else {
            sprite.setColor(Color.GREEN);
            sprite.setAlpha(0.5f);
        }
        sprite.setPosition(_tile.getCords().x, _tile.getCords().y);
        sprite.draw(_batch);
        _batch.end();
    }
}
GameActor.java 文件源码 项目:alquran-alkarem 阅读 23 收藏 0 点赞 0 评论 0
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height) {
actor_texture = actor_region;
xpos = x_pos ;
ypos = y_pos ;
width_ =width ;
height_ = height;
actor_Sprite = new Sprite(actor_texture);
actor_Sprite.setX(xpos);
actor_Sprite.setY(ypos);
if(color != null){   
actor_Sprite.setColor(color);}
actor_Sprite.setSize(width_, height_);
actor_Sprite.setOrigin(width_/2, height_/2);
setBounds(xpos, ypos, width_, height_);
this.setTouchable(Touchable.enabled);
}
ChrRamPatternTableManager.java 文件源码 项目:ggvm 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void initialize() {
    //Allocate a pixmap big enough to accommodate four banks of pattern
    //tables (bg and spr each for all four banks)
    patternTablePixmap = new Pixmap(128, 1024, Pixmap.Format.RGBA8888);
    //Set blending to none so we can rewrite the pixmap and draw it to the
    //pattern table texture when graphics are regenerated.
    patternTablePixmap.setBlending(Pixmap.Blending.None);

    //Allocate a pixmap the size of one tile for live CHR-RAM updates.
    patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
    patternPixmap.setBlending(Pixmap.Blending.None);

    patternTableTexture = new Texture(patternTablePixmap, false);
    TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8);
    patternTableSprites = new Sprite[128][16];
    for(int row = 0; row < 128; row++) {
        for(int column = 0; column < 16; column++) {
            TextureRegion textureRegion = textureRegions[row][column];
            patternTableSprites[row][column] = new Sprite(textureRegion);
        }
    }
    initializeMonochromePalette();
}
GameActor.java 文件源码 项目:alquran-alkarem 阅读 26 收藏 0 点赞 0 评论 0
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height,boolean is_loading) {
actor_texture = actor_region;
xpos = x_pos ;
ypos = y_pos ;
width_ =width ;
height_ = height;
actor_Sprite = new Sprite(actor_texture);
actor_Sprite.setX(xpos);
actor_Sprite.setY(ypos);
if(color != null){
actor_color = color ;
actor_Sprite.setColor(actor_color);}
actor_Sprite.setSize(width_, height_);

}
Trajectory.java 文件源码 项目:Planet-Generator 阅读 19 收藏 0 点赞 0 评论 0
public Trajectory(Orbiter orbiter) {
    this.orbiter = orbiter;
    int degreeIncrement = 10;
    speed = 10;

    Array<Orbiter> pathObjects = new Array<Orbiter>();
    for(int i = 0; i < 360; i += degreeIncrement) {
        Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
        orbiterBlueprint.angle = i;
        orbiterBlueprint.angularVelocity = speed;
        orbiterBlueprint.radius = orbiter.getRadius();
        orbiterBlueprint.xTilt = orbiter.getXTilt();
        orbiterBlueprint.zTilt = orbiter.getZTilt();

        Sprite trajectoryDot = new Sprite(Scene.pixelTexture);
        Color color = new Color();
        Color.rgba8888ToColor(color, orbiter.getColor());
        trajectoryDot.setColor(color);
        trajectoryDot.setSize(2, 2);

        pathObjects.add(new Orbiter(trajectoryDot, orbiterBlueprint));
    }
    path = new Ring(pathObjects);
}
SorahTab.java 文件源码 项目:alquran-alkarem 阅读 23 收藏 0 点赞 0 评论 0
public MakeMadany(int sorah_no){ 
    // TODO Auto-generated constructor stub
    goza_name_texture = book.get_region(suar_state[sorah_no-1]?"makah":"madinah");
    Goza_name_sprite = new Sprite(goza_name_texture);
    height = tab_height ;
    width = height; 
    Goza_name_sprite.setSize(width, height);
    no = sorah_no ;
    x = sorah_page_no_width+(sorah_tanzel_width-width)/2 ;
    y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
    text_y_deferance=2*tab_height/3;
    surah_page_no = new TextActor(""+surah_page[no-1],
            null,
            sorah_page_no_width,
            TextAlign.align_cinter, tab_no_text_scale,0,text_y_deferance+y);

}
GameState.java 文件源码 项目:KyperBox 阅读 22 收藏 0 点赞 0 评论 0
public GameState(String name, String tmx, StateManager manager) {
    this.tmx = tmx;
    setManager(manager);
    if(name!=null)
    this.name = name;
    else
        this.name = "";
    sprites = new ObjectMap<String, Sprite>();
    animations = new ObjectMap<String, Animation<String>>();
    fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
    particle_effects = new ObjectMap<String, ParticleEffectPool>();
    pvalues = new Array<String>();
    time_scale = 1f;
    shaders = new ObjectMap<String, ShaderProgram>();
    svalues = new Array<String>();
}
SpaceObject.java 文件源码 项目:Planet-Generator 阅读 21 收藏 0 点赞 0 评论 0
public SpaceObject(Sprite sprite, int color) {
    this.sprite = sprite;
    this.color = color;

    drawColor = new Color(color);

    if(sprite != null) {
        this.size = (int)sprite.getWidth();
    }
}
SavingLoadingTests.java 文件源码 项目:Planet-Generator 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void testCloudJson() {
    Array<Orbiter> orbiters = new Array<>();
    Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
    orbiterBlueprint.angularVelocity = 70;
    int cloudObjectsCount = 10;
    for(int i = 0; i < cloudObjectsCount; i++) {
        orbiters.add(new Orbiter(new Sprite(), orbiterBlueprint));
    }

    Cloud saveCloud = new Cloud(orbiters);

    String cloudJson = json.toJson(saveCloud);
    assertNotEquals("", cloudJson);

    Cloud loadCloud = json.fromJson(Cloud.class, cloudJson);

    assertNotEquals(null, loadCloud);
    assertEquals(cloudObjectsCount, loadCloud.getCloudObjects().size);
    assertEquals(70, loadCloud.getAngularVelocity());
}
SorahTab.java 文件源码 项目:alquran-alkarem 阅读 24 收藏 0 点赞 0 评论 0
public GozaName(int goza_no) {
    // TODO Auto-generated constructor stub
    goza_name_texture = book.get_region("s"+goza_no);
    Goza_name_sprite = new Sprite(goza_name_texture);
    width = sorah_name_width ; 
    height = tab_height ;
    Goza_name_sprite.setSize(width, height);
    no = goza_no ;
    text_y_deferance=2*tab_height/3;
    x = (sorah_page_no_width+sorah_tanzel_width+ayat_widht)+sorah_tab_book_mark_width*3  ;
    y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));

    no_of_surah = new TextActor(no+"",
            null,
            tab_no_width,
            TextAlign.align_cinter,tab_no_text_scale,x+sorah_name_width, text_y_deferance+y);
}
SPLASH.java 文件源码 项目:Ponytron 阅读 26 收藏 0 点赞 0 评论 0
private void setupSplashImage() {
    DS.game.manager.load(splashImgFilename, Texture.class);
    manager.finishLoading();
    splashLogo = new Sprite(DS.game.manager.get(splashImgFilename, Texture.class));
    splashLogo.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    double SCALE = DS.T_WIDTH/splashLogo.getWidth();

    if(DS.app_orientation == DS.ORIENTATION.PORTRAIT) {
        splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
    } else {
        SCALE = DS.T_HEIGHT/splashLogo.getHeight();
        splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
    }
    int imgX = (int)(DS.T_WIDTH/2.0 - splashLogo.getWidth()/2.0);
    int imgY = (int)(DS.T_HEIGHT/2.0 - splashLogo.getHeight()/2.0);
    Gdx.app.debug(ID, "splshlogo Width: " + splashLogo.getWidth());
    Gdx.app.debug(ID, "splshlogo Height: " + splashLogo.getHeight());
    Gdx.app.debug(ID, "imgX: " + imgX);
    Gdx.app.debug(ID, "imgY: " + imgY);
    splashLogo.setPosition(imgX, imgY);
}
AnimationPlayer.java 文件源码 项目:GDX-Engine 阅读 19 收藏 0 点赞 0 评论 0
public void PlayAnimation(Sprite sprite, Animation animation,
    Rectangle newRegionOnTexture) {
if (animation == null && this.animation == null)
    throw new GdxRuntimeException("No animation is currently playing.");
// If this animation is already running, do not restart it.
if (this.animation == animation)
    return;

// Start the new animation.
this.animation = animation;
this.frameIndex = 0;
this.animationTimeline = 0.0f;

sprite.setRegionX((int) newRegionOnTexture.x);
sprite.setRegionY((int) newRegionOnTexture.y);
sprite.setRegionWidth((int) newRegionOnTexture.getWidth());
sprite.setRegionHeight((int) newRegionOnTexture.getHeight());
onAnimationChanged();
   }
TiledScene.java 文件源码 项目:GDX-Engine 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Initialize position of sprite by the position of object from tiled map.
 * If size 's values is not zero, the sprite will be scaled by the new size
 * 
 * @param sprite
 *            the sprite will receive changes from tiled object
 * @param object
 *            tiled object from tiled map
 * @param size
 */
public void initilizeTileObject(Sprite sprite, TiledObject object,
        float size) {

    sprite.setX(object.x + object.width / 2);
    sprite.setY(tileMapRenderer.getMapHeightUnits() - object.y
            - object.height / 2);
    if (size > 0) {
        float s = object.width / size;
        sprite.setScale(s);
    }
}
MyGdxGame.java 文件源码 项目:GDX-Engine 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void create() {      
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera(1, h/w);
    batch = new SpriteBatch();

    texture = new Texture(Gdx.files.internal("data/libgdx.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200);

    sprite = new Sprite(region);
    sprite.setSize(1f,  sprite.getHeight() / sprite.getWidth());
    sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
    sprite.setPosition(-.5f, -.5f);

}
Principal.java 文件源码 项目:TomiFlowGDX 阅读 33 收藏 0 点赞 0 评论 0
@Override
public void create () {
     batch = new SpriteBatch();
     img = new Texture("coche.png");
     miCoche= new Sprite(img);
     miCoche.setPosition(0,20);
     miCoche.setSize(200,100);

}
Player.java 文件源码 项目:EarthInvadersGDX 阅读 27 收藏 0 点赞 0 评论 0
public Player() {
    super(0, 0);
    this.x = (float) (GameScreen.earth.getXCenter() + radius * Math.sin(angle));
    this.y = (float) (GameScreen.earth.getYCenter() + radius * Math.cos(angle));
    img = new Sprite(new Texture(Gdx.files.internal("player.png")));
    shoot = new Sound[4];
    for (int i = 1; i <= shoot.length; i++) {
        shoot[i - 1] = Gdx.audio.newSound(Gdx.files.internal("sound/shoot" + i + ".wav"));
    }
}
MenuScreen.java 文件源码 项目:EarthInvadersGDX 阅读 22 收藏 0 点赞 0 评论 0
public MenuScreen() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
    viewport.apply();
    camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
    camera.update();
    betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
    betaText.getData().setScale(0.35f);
    logo = new Sprite(new Texture("logo.png"));
    Random r = new Random();
    background = new Particle[r.nextInt(55 - 45) + 45];
    for (int i = 0; i < background.length; i++) {
        int size = r.nextInt(4) + 1;
        int x = r.nextInt(Game.WIDTH);
        int y = r.nextInt(Game.HEIGHT);
        background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size);
    }
    musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
    musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
    play = new CenteredButton(500, "buttons/play.png");
    music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
    music.setScale(4f);
}
BurgerExplosion.java 文件源码 项目:Ponytron 阅读 20 收藏 0 点赞 0 评论 0
public void init() {
    topBunSprite = new Sprite(AssetDoctor.getSprite("burger_top_bun"));
    burgerSprite = new Sprite(AssetDoctor.getSprite("burger_burger"));
    lettuceSprite = new Sprite(AssetDoctor.getSprite("burger_lettuce"));
    bottomBunSprite = new Sprite(AssetDoctor.getSprite("burger_bottom_bun"));
    resizeSprite(topBunSprite);
    resizeSprite(lettuceSprite);
    resizeSprite(burgerSprite);
    resizeSprite(bottomBunSprite);

    topBunSprite.setPosition(x - topBunSprite.getWidth()/2.0f, y - topBunSprite.getHeight()/2.0f + 20.0f);
    lettuceSprite.setPosition(x - lettuceSprite.getWidth()/2.0f, y - lettuceSprite.getHeight()/2.0f);
    burgerSprite.setPosition(x - burgerSprite.getWidth()/2.0f, y - burgerSprite.getHeight()/2.0f - 10.0f);
    bottomBunSprite.setPosition(x - bottomBunSprite.getWidth()/2.0f, y - bottomBunSprite.getHeight()/2.0f - 20.0f);

    CURRENT_STATE = STATE.LIVE;
}
HealthSystem.java 文件源码 项目:ExamensArbeteTD 阅读 17 收藏 0 点赞 0 评论 0
private void drawHealthBar(HealthComponent healthComp, PositionComponent pos) {
    final float healthBarHeight = Assets.enemyRedHealthbarBG.getHeight();
    final float healthBarWidth = Assets.enemyRedHealthbarBG.getWidth();
    // getting the scale ratio
    final double ratio = healthBarWidth / healthComp.maxHealth;
    Sprite spriteBg = Assets.enemyRedHealthbarBG;
    Sprite sprite = Assets.enemyGreenHealthbarBG;
    // todo center hp bar
    sprite.setPosition(pos.position.x, pos.position.y);
    spriteBg.setPosition(pos.position.x, pos.position.y);
    if(healthComp.health > 0)
        sprite.setSize((float) (ratio * healthComp.health), healthBarHeight);
    // 100 %
    if (healthComp.health <= healthComp.maxHealth)
        sprite.setColor(0, 0.75f, 0, 1f);
    // 75 %
    if (healthComp.health <= 0.75 * healthComp.maxHealth)
        sprite.setColor(Color.YELLOW);
    // 50%
    if (healthComp.health <= 0.50 * healthComp.maxHealth)
        sprite.setColor(Color.ORANGE);
    // 25%
    if (healthComp.health <= 0.25 * healthComp.maxHealth)
        sprite.setColor(Color.BROWN);
    // if enemy isn't hurt don't draw health.
    if (healthComp.health != healthComp.maxHealth) {
        _batch.begin();
        spriteBg.draw(_batch);
        sprite.draw(_batch);
        _batch.end();
    }
}
PlayerHelper.java 文件源码 项目:arcadelegends-gg 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns a shaded sprite for coloring the ability icons. Controlled by the {@link Character} class.
 *
 * @param ability for the overlay sprite
 * @return the overlay sprite
 */
public Sprite getAbilityOverlaySprite(int ability) {
    CharacterComponent characterComponent = arcadeWorld.getEntityWorld().getMapper(CharacterComponent.class).get(entityId);
    Color color;
    if ((color = characterComponent.character.getAbilityOverlay(ability)) != null)
        abilityOverlaySprites[ability].setColor(color);
    else
        abilityOverlaySprites[ability].setColor(0, 0, 0, 0);
    return abilityOverlaySprites[ability];
}
SPLASH.java 文件源码 项目:Ponytron 阅读 32 收藏 0 点赞 0 评论 0
private void setup_a_sprites(TextureAtlas atlas) {
    a_sprites.add(AssetDoctor.loadSprite_ATLAS("border", atlas.createSprite("border")));

    for(Sprite s : b_sprites) {
        s.setSize(s.getWidth()*DS.SCALE, s.getHeight()*DS.SCALE);
    }
}
SingleScreenMirroringRenderManager.java 文件源码 项目:ggvm 阅读 23 收藏 0 点赞 0 评论 0
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
    int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;

    boolean toggleNametableEarly = false;
    if (scrollY > 239 && scrollY <= 255) {
        scrollY -= 16;
        toggleNametableEarly = true;
    }

    int coarseScrollX = scrollX >> 3;
    int coarseScrollY = scrollY >> 3;
    int fineScrollX = scrollX & 7;
    int fineScrollY = scrollY & 7;

    int nameTableX = coarseScrollX;
    int nameTableY = coarseScrollY;
    int actualNameTableX;
    int actualNameTableY;
    int screenX = 0;
    int screenY = 8;
    int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
    int nameTableColumnCount = 33;
    int nameTable;

    while (nameTableColumnCount > 0) {
        screenY = 0;
        nameTableRowCount = fineScrollY == 0 ? 30 : 31;
        nameTableY = coarseScrollY;
        nameTable = (ggvm.getNametableAddress() == Ppu.NAME_TABLE_0_BASE_ADDRESS) ? 0 : 1;
        if (toggleNametableEarly) {
            nameTable ^= 1;
        }
        while (nameTableRowCount > 0) {
            actualNameTableX = nameTableX % 32;
            actualNameTableY = nameTableY % 30;

            int nameTableAddress = nameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
            int attributeTableAddress = nameTableAddress == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;

            int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
            int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);

            int indexRow = index >> 4;
            int indexColumn = index & 0x0f;
            Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
            sprite.setColor(0, attributes[attribute], 0, 0);
            //if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
                sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
                sprite.draw(spriteBatch);
            //}
            screenY += 8;
            nameTableY++;
            nameTableRowCount--;
        }
        screenX += 8;
        nameTableX++;
        nameTableColumnCount--;
    }
}
VerticalMirroringRenderManager.java 文件源码 项目:ggvm 阅读 22 收藏 0 点赞 0 评论 0
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int startingNametableAddress, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
    int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;

    int coarseScrollX = scrollX >> 3;
    int coarseScrollY = scrollY >> 3;
    int fineScrollX = scrollX & 7;
    int fineScrollY = scrollY & 7;

    int nameTableX = coarseScrollX;
    int nameTableY = coarseScrollY;
    int actualNameTableX;
    int actualNameTableY;
    int screenX = 0;
    int screenY = 0;
    int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
    int nameTableColumnCount;
    int nameTable;

    while (nameTableRowCount > 0) {
        screenX = 0;
        nameTableColumnCount = fineScrollX == 0 ? 32 : 33;
        nameTableX = coarseScrollX;
        nameTable = (startingNametableAddress == Ppu.NAME_TABLE_0_BASE_ADDRESS || startingNametableAddress == Ppu.NAME_TABLE_2_BASE_ADDRESS) ? 0 : 1;
        while (nameTableColumnCount > 0) {
            actualNameTableX = nameTableX % 32;
            actualNameTableY = nameTableY % 30;
            int whichNameTable = nameTable ^ ((nameTableX >> 5) & 1);

            int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
            int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;

            int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
            int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);

            int indexRow = index >> 4;
            int indexColumn = index & 0x0f;
            Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
            sprite.setColor(0, attributes[attribute], 0, 0);
            if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
                sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
                sprite.draw(spriteBatch);
            }
            screenX += 8;
            nameTableX++;
            nameTableColumnCount--;
        }
        screenY += 8;
        nameTableY++;
        nameTableRowCount--;
    }
}
Splashscreen.java 文件源码 项目:school-game 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Initialisierung
 *
 * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
 */
@Override
public void create(SchoolGame game) {
    this.game = game;
    batch = new SpriteBatch();

    Texture splashImg = new Texture(Gdx.files.internal("data/misc/splashscreen.png"));
    screenSprite = new Sprite(splashImg);
    screenSprite.setPosition(-screenSprite.getWidth() / 2, -screenSprite.getHeight() / 2);
    screenSprite.setAlpha(0);

    timer = SHOW_TIME + FADE_TIME * 2;
}
GameObjectFactory.java 文件源码 项目:Race99 阅读 27 收藏 0 点赞 0 评论 0
public static GameObject createGameObjectWithBox2DBody(Vector2 gameObjectPos, Texture texture, Vector3 densityFrictionRestitution,
                                   BodyDef.BodyType bodyType, Shape.Type shapeType,
                                   World world) {
    GameObject gameObject = new GameObject();
    gameObject.setPosition(gameObjectPos.x, gameObjectPos.y);
    gameObject.setTexture(texture);
    gameObject.setSprite(new Sprite(texture));
    gameObject.getSprite().setOriginCenter();
    gameObject.setWorld(world);
    BodyCreator bodyCreator = new BodyCreator();
    gameObject.setBody(bodyCreator.createBody(new Vector2(gameObject.getX(), gameObject.getY()), texture, bodyType, world, shapeType, densityFrictionRestitution));
    bodyCreator = null;
    return gameObject;
}
Scene.java 文件源码 项目:Planet-Generator 阅读 27 收藏 0 点赞 0 评论 0
private void createPlanet(int velDir) {
    Pixmap pixmap = generatePlanetPixmap(1024);
    Sprite planet = new Sprite(new Texture(pixmap));
    int size = MathUtils.random(100, 148);
    planet.setSize(size, size);
    planet.setPosition(CENTER_X - planet.getWidth() / 2, CENTER_Y - planet.getHeight() / 2);
    this.planet = new Planet(planet, pixmap, velDir);
    spaceObjects.add(this.planet);
}
Scene.java 文件源码 项目:Planet-Generator 阅读 29 收藏 0 点赞 0 评论 0
private void loadPlanet(Json json, JsonValue jsonData) {
    planet = json.readValue("planet", Planet.class, jsonData);

    Pixmap loadPixmap = new Pixmap(1024, 1024, Pixmap.Format.RGBA8888);
    int index = 0;
    for(int x = 0; x < 1024; x++) {
        for (int y = 0; y < 1024; y++) {
            int color = 0;
            switch (planet.getTextureString().charAt(index)) {
                case 'd':
                    color = Color.rgba8888(47f / 255f, 86f / 255f, 118f / 255f, 1f);
                    break;

                case 'o':
                    color = Color.rgba8888(62f / 255f, 120f / 255f, 160f / 255f, 1f);
                    break;

                case 'l':
                    color = Color.rgba8888(146f / 255f, 209f / 255f, 135f / 255f, 1f);
                    break;
            }

            index++;

            loadPixmap.setColor(color);
            loadPixmap.drawPixel(x, y);
        }
    }

    Sprite sprite = new Sprite(new Texture(loadPixmap));
    sprite.setSize(planet.getSize(), planet.getSize());
    sprite.setPosition(CENTER_X - planet.getSize() / 2, CENTER_Y - planet.getSize() / 2);
    planet = new Planet(sprite, loadPixmap, objectGenerator.getVelDir());

    spaceObjects.add(planet);
}
Star.java 文件源码 项目:Planet-Generator 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void read(Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    setSprite(new Sprite());
    int size = json.readValue("size", Integer.class, jsonData);
    getSprite().setSize(size, size);
    int x = json.readValue("xPos", Integer.class, jsonData);
    int y = json.readValue("yPos", Integer.class, jsonData);
    getSprite().setPosition(x, y);
}
Orbiter.java 文件源码 项目:Planet-Generator 阅读 25 收藏 0 点赞 0 评论 0
public Orbiter(Sprite sprite, OrbiterBlueprint blueprint, int color) {
        super(sprite, color);

        this.angularVelocity = blueprint.angularVelocity;
        this.zTilt = blueprint.zTilt;
        this.xTilt = blueprint.xTilt;
        this.angle = blueprint.angle;
        this.radius = blueprint.radius;
        this.yOffset = blueprint.yOffset;

//        setColor(color);

        initializeMatrices();
    }
Planet.java 文件源码 项目:Planet-Generator 阅读 30 收藏 0 点赞 0 评论 0
public Planet(Sprite sprite, Pixmap pixmap, int direction) {
    super(sprite);
    this.pixmap = pixmap;
    this.direction = direction;

    rotationSpeed = 1/50f;
    radius = sprite.getWidth()/2;

    planetShader = new ShaderProgram(Gdx.files.internal("shaders/planet.vsh"), Gdx.files.internal("shaders/planet.fsh"));
    if(!planetShader.isCompiled()) {
        Gdx.app.error("Planet Shader Error", "\n" + planetShader.getLog());
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号