public MainMenuScreen(MissileCommand game) { this.game = game; guiCam = new OrthographicCamera( com.intel.libgdxmissilecommand.common.Assets.screenWidth, com.intel.libgdxmissilecommand.common.Assets.screenHeight); guiCam.position.set( com.intel.libgdxmissilecommand.common.Assets.screenWidth / 2, com.intel.libgdxmissilecommand.common.Assets.screenHeight / 2, 0); startButton = new Sprite(com.intel.libgdxmissilecommand.common.Assets.startButtonTextureRegion); startButton.setPosition( com.intel.libgdxmissilecommand.common.Assets.screenWidth / 2 - startButton.getWidth() / 2, startButton.getHeight() * 2.5f); creditsButton = new Sprite(com.intel.libgdxmissilecommand.common.Assets.creditsButtonTextureRegion); creditsButton.setPosition( com.intel.libgdxmissilecommand.common.Assets.screenWidth / 2 - creditsButton.getWidth() / 2, creditsButton.getHeight()); touchPoint = new Vector3(); }
private void createSprites() { // background backgroundTexture = new Texture(Gdx.files.internal("data/cr/map1bg.png")); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); backgroundSprite = new Sprite(backgroundTexture); backgroundSprite.setSize(WIDTH_WORLD, HEIGHT_WORLD); backgroundSprite.setPosition(-WIDTH_WORLD / 2f, 0); // planet planetTexture = new Texture(Gdx.files.internal("data/cr/planet_terrain.png")); planetTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); planetSprite = new Sprite(planetTexture); planetSprite.setSize( PLANET_WIDTH, PLANET_WIDTH * planetSprite.getHeight() / planetSprite.getWidth()); // planet core planetCoreTexture = new Texture(Gdx.files.internal("data/cr/planet_core.png")); planetCoreTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); planetCoreSprite = new Sprite(planetCoreTexture); planetCoreSprite.setSize( PLANET_CORE_WIDTH, PLANET_CORE_WIDTH * planetCoreSprite.getHeight() / planetCoreSprite.getWidth()); // balls ballTexture = new Texture(Gdx.files.internal("data/gfx/ball.png")); ballTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); ballSprites = new Sprite[MAX_BALLS]; for (int i = 0; i < MAX_BALLS; i++) { ballSprites[i] = new Sprite(ballTexture); ballSprites[i].setSize(BALL_RADIUS * 2, BALL_RADIUS * 2); ballSprites[i].setOrigin(BALL_RADIUS, BALL_RADIUS); } }
@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); texture_nave = new Texture(Gdx.files.internal("data/nave.png")); sprite_nave = new Sprite(texture_nave, 128, 64); sprite_nave.setPosition(-0.5f, -0.5f); sprite_nave.setSize(0.5f, 0.5f); TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275); sprite = new Sprite(region); sprite2 = new Sprite(region); sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth()); sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2); sprite.setPosition(-sprite.getWidth() / 2, -sprite.getHeight() / 2); sprite.setPosition(0, 0); sprite.setRotation(25); }
@Override public void show() { Texture.setEnforcePotImages(false); butBatch = new SpriteBatch(); logoMenuBatch = new SpriteBatch(); splashBatch = new SpriteBatch(); logoTexture = new Texture("resources/logo.png"); splashTexture = new Texture("resources/teamlogo.png"); splashBGTexture = new Texture("resources/background2.png"); menuBGTexture = new Texture("resources/menubg.png"); splashSprite = new Sprite(splashTexture); splashBGSprite = new Sprite(splashBGTexture); logoSprite = new Sprite(logoTexture); menuBGSprite = new Sprite(menuBGTexture); logoSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2); logoSprite.setY(Gdx.graphics.getHeight() / 2 - Gdx.graphics.getHeight() / 7); splashSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2); splashSprite.setY(Gdx.graphics.getHeight() / 7); // buttons butAtlas = new TextureAtlas("resources/button.pack"); butSkin = new Skin(); butSkin.addRegions(butAtlas); font1 = new BitmapFont(Gdx.files.internal("resources/font_black.fnt"), false); }
/** @param path */ public LoadTexture(String path) { array_Texs.add(new Texture(path)); array_Texs.get(BACKGROUND).setFilter(TextureFilter.Linear, TextureFilter.Linear); array_Texs.add(new Texture(Gdx.files.internal("data/arrow-down.png"))); array_Texs.add(new Texture(Gdx.files.internal("data/arrow-up.png"))); array_Texs.add(new Texture(Gdx.files.internal("data/menu.png"))); for (int i = 0; i < array_Texs.size(); i++) { array_TexRegions.add( new TextureRegion( array_Texs.get(i), 0, 0, array_Texs.get(i).getWidth(), array_Texs.get(i).getHeight())); array_Sprites.add(new Sprite(array_TexRegions.get(i))); } // 背景画像設定 Sprite sprite = array_Sprites.get(BACKGROUND); sprite.setSize(sprite.getRegionWidth(), sprite.getRegionHeight()); sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2); sprite.setPosition(-sprite.getWidth() / 2, -sprite.getHeight() / 2); array_Sprites.set(BACKGROUND, sprite); }
public Fly(float x, float y, int fly_type, int slot_number) { // set static data of fly(x, y, ect) xCoord = x; yCoord = y; fly_size = fly_type; slotNumber = slot_number; switch (fly_type) { case 1: // small fly texture = new Texture(Gdx.files.internal("data/medium_fly.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); TextureRegion region = new TextureRegion(texture, 0, 0, 212, 143); fly_sprite = new Sprite(region); fly_sprite.setSize(.0745f, .06155f); fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2); fly_sprite.setPosition(x, y); break; case 2: // small fly texture = new Texture(Gdx.files.internal("data/medium_fly.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); region = new TextureRegion(texture, 0, 0, 212, 143); fly_sprite = new Sprite(region); fly_sprite.setSize(.0745f, .06155f); fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2); fly_sprite.setPosition(x, y); break; case 3: // medium fly texture = new Texture(Gdx.files.internal("data/medium_fly.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); region = new TextureRegion(texture, 0, 0, 212, 143); fly_sprite = new Sprite(region); fly_sprite.setSize(.115f, .097f); fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2); fly_sprite.setPosition(x, y); break; case 4: // large fly texture = new Texture(Gdx.files.internal("data/medium_fly.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); region = new TextureRegion(texture, 0, 0, 212, 143); fly_sprite = new Sprite(region); fly_sprite.setSize(.155f, .135f); fly_sprite.setOrigin(fly_sprite.getWidth() / 2, fly_sprite.getHeight() / 2); fly_sprite.setPosition(x, y); break; default: break; } }
/** コンストラクタ */ public Interface() { weapon = new ArrayList<Sprite>(); // テクスチャ画像読み込み Texture texture = new Texture(Gdx.files.internal("data/interface.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); // 巻物アニメーション TextureRegion[][] tmp = TextureRegion.split(texture, 128, 128); TextureRegion[] frame = new TextureRegion[3]; int index = 0; for (int i = 0; i < frame.length; i++) frame[index++] = tmp[0][i]; scrollAnimation = new Animation(5.0f, frame); scroll = new Sprite(scrollAnimation.getKeyFrame(0, false)); scroll.setOrigin(scroll.getWidth() * 0.5f, scroll.getHeight() * 0.5f); scroll.setScale(ScrollNinja.scale); nowFrame = scrollAnimation.getKeyFrame(0, false); // HP部分 TextureRegion tmpRegion = new TextureRegion(texture, 0, 128, 512, 128); hp = new Sprite(tmpRegion); hp.setOrigin(hp.getWidth() * 0.5f, hp.getHeight() * 0.5f); hp.setScale(ScrollNinja.scale); // 巻物の右端部分 tmpRegion = new TextureRegion(texture, 384, 0, 128, 128); scrollRight = new Sprite(tmpRegion); scrollRight.setOrigin(scrollRight.getWidth() * 0.5f, scrollRight.getHeight() * 0.5f); scrollRight.setScale(ScrollNinja.scale); // ひょうたん tmpRegion = new TextureRegion(texture, 0, 256, 128, 128); hyoutan = new Sprite(tmpRegion); hyoutan.setOrigin(hyoutan.getWidth() * 0.5f, hyoutan.getHeight() * 0.5f); hyoutan.setScale(ScrollNinja.scale); // チャクラ tmpRegion = new TextureRegion(texture, 128, 256, 128, 128); chakra = new Sprite(tmpRegion); chakra.setOrigin(chakra.getWidth() * 0.5f, chakra.getHeight() * 0.5f); chakra.setScale(ScrollNinja.scale); // 最初の設定; percentHP = 1; countHP = percentHP; percentChakra = 0; countChakra = percentChakra; calculateHP = false; calculateChakra = false; stopHP = true; stopChakra = true; stateTime = 0; transrateX = 0; }
private void initialize() { switch (scene) { case 5: enemySprite = new Sprite(assets.animationBigEnemy.getKeyFrame(0.1f)); enemySprite.setSize(enemySprite.getWidth() / 2, enemySprite.getHeight() / 2); speed = 5f; type = enemyBIG; enemyRec = new Rectangle( startPos.x, startPos.y, enemySprite.getWidth() - 10, enemySprite.getHeight()); // Range normalRange = 500; targetRange = 500; // Freeze freezeTime = 1; soundController = 0; break; default: enemySprite = new Sprite(assets.animationNormalEnemyRight.getKeyFrame(0.1f)); enemySprite.setSize(enemySprite.getWidth() / 2, enemySprite.getHeight() / 2); speed = 8f; type = enemyNORMAL; enemyRec = new Rectangle( startPos.x, startPos.y, enemySprite.getWidth() - 5, enemySprite.getHeight()); // Range normalRange = 50; targetRange = 80; freezeTime = 3; break; } stateTime = 0; isTarget = false; isFreeze = false; freezeController = 0; // Horizontal if (pol.getVertices()[0] != pol.getVertices()[2]) { isHorizontal = true; if (pol.getVertices()[2] < 0) { isLeft = true; } } // Vertical else if (pol.getVertices()[1] != pol.getVertices()[3]) { isHorizontal = false; // isUp = true; if (this.pol.getVertices()[3] < 0) { this.pol.getVertices()[3] *= -1; } } }
@Override public void create() { // creates everything you need LOL batch = new SpriteBatch(); img = new Texture("Alien.png"); sprite = new Sprite(img); // sets the sprite in the middle of the screen sprite.setPosition( Gdx.graphics.getWidth() / 2 - sprite.getWidth() / 2, Gdx.graphics.getHeight() / 2); // This is were the magic happens, this is the "physics world" created where the gravity is set // to 98 // The 'f' makes 98 a float, the true means that it is active, vector 2d just means it takes x y // coor world = new World(new Vector2(0, -98f), true); // The body is the "object" set in the world, BodyDef makes the world aware of the object // basically so world Senpai notices BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; // using 1 to 1 dimensions, meaning 1 in physics engine is 1px // set the body to the same position as the sprite bodyDef.position.set(sprite.getX(), sprite.getY()); // now create the body in the world! body = world.createBody(bodyDef); // now make the "shape" of the body that you just created shape = new PolygonShape(); // in this example I made a box (you can make circles too and stuff) that surrounds the sprite // aka the hit-box // so make the shape the same dimensions as the sprite image we are using shape.setAsBox(sprite.getWidth() / 2, sprite.getHeight() / 2); // FixtureDef is used to add physical properties to the shape // Ex. density, mass, area etc. fixtureDef = new FixtureDef(); // now assign the FixtureDef to the new shape that we just made fixtureDef.shape = shape; // Adding density using FixtureDef & adding it to the body so again world senpai notices fixtureDef.density = 1f; fixture = body.createFixture(fixtureDef); // the shape can be disposed to reduce clutter that will slow down the game shape.dispose(); }
/** * An Entity with a square physics Body. * * @param sprite the sprite for this * @param friction the coefficient of friction for this * @param restitution the restitution for this * @param world the physics world that is in * @param mass the mass of this in grams * @param x the x ordinate of this in pixels * @param y the y ordinate of this in pixels * @param isStatic if this is capable of having motion * @param canRotate if this is capable of rotating */ public SpriteEntity( float scale, Sprite sprite, float friction, float restitution, World world, float mass, float x, float y, boolean isStatic, boolean canRotate) { this( scale, sprite, friction, restitution, world, mass, x, y, sprite.getWidth(), sprite.getHeight(), isStatic, canRotate); }
@Override public void show() { sprite = new Sprite(AssetLoader.logo); sprite.setColor(1, 1, 1, 0); float width = Gdx.graphics.getWidth(); float height = Gdx.graphics.getHeight(); float desiredWidth = width * .7f; float scale = desiredWidth / sprite.getWidth(); sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale); sprite.setPosition( (width / 2) - (sprite.getWidth() / 2), (height / 2) - (sprite.getHeight() / 2)); setupTween(); batcher = new SpriteBatch(); }
@Override public void create() { GeneralStorage.load(); MenuStorage.load(); SplashStorage.load(); MenuStorage.load(); PauseStorage.load(); RunningStorage.load(); GameOverStorage.load(); GeneralStorage.estado = GeneralStorage.state.splash; MenuStorage.HelpTouched = false; // Init the particle effect particle1 = new ParticleEffect(); particleLeft = new ParticleEffect(); particleRight = new ParticleEffect(); // load the particle, first parameter is path and name file when is the particle, // second one the fold when is the particle image. particle1.load(Gdx.files.internal("efectos/vuelo2"), Gdx.files.internal("efectos")); particleLeft.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos")); particleRight.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos")); // Sprites of button of the menu screen to music, sound and button help spHelp = new Sprite(GeneralStorage.imgBTHelp); spHelp.setSize(GeneralStorage.w / 10, GeneralStorage.w / 10); spHelp.setPosition( GeneralStorage.w - GeneralStorage.w / 4 - spHelp.getWidth() / 2, GeneralStorage.h / 4); // storage the background color colorFondo = MenuStorage.spBackGroundGame.getColor(); // Time to splash screen. timer = 100; }
@Override public void render() { camera.update(); // Step the physics simulation forward at a rate of 60hz world.step(1f / 60f, 6, 2); sprite.setPosition( (body.getPosition().x * PIXELS_TO_METERS) - sprite.getWidth() / 2, (body.getPosition().y * PIXELS_TO_METERS) - sprite.getHeight() / 2); sprite.setRotation((float) Math.toDegrees(body2.getAngle())); sprite2.setPosition( (body2.getPosition().x * PIXELS_TO_METERS) - sprite2.getWidth() / 2, (body2.getPosition().y * PIXELS_TO_METERS) - sprite2.getHeight() / 2); sprite2.setRotation((float) Math.toDegrees(body.getAngle())); Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw( sprite, sprite.getX(), sprite.getY(), sprite.getOriginX(), sprite.getOriginY(), sprite.getWidth(), sprite.getHeight(), sprite.getScaleX(), sprite.getScaleY(), sprite.getRotation()); batch.draw( sprite2, sprite2.getX(), sprite2.getY(), sprite2.getOriginX(), sprite2.getOriginY(), sprite2.getWidth(), sprite2.getHeight(), sprite2.getScaleX(), sprite2.getScaleY(), sprite2.getRotation()); batch.end(); }
public void update() { if (body.getUserData() == Constants.robotNinjaID) { body.setLinearVelocity(Constants.standardVelocity.x, 0); } sprite.setPosition( body.getPosition().x - sprite.getWidth() / 2, body.getPosition().y - sprite.getHeight() / 2); }
// ============================================================================================== // NOT BOX 2D STUFF JUST COOL THINGS I ADDED TO MAKE THE PROGRAM MORE "FUN" public void HandleTouch() { float fSprite_Width = sprite.getWidth(); float fSprite_Height = sprite.getHeight(); if (Gdx.input.isTouched()) { Vector3 touchPos = new Vector3(); // Using vector 3 as a 2-D vector for touch coordinates touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0); body.setTransform(touchPos.x - (fSprite_Width / 2), (touchPos.y - (fSprite_Height / 2)), 0); } }
public void victory() { victory.setPosition( -victory.getWidth() / 2 + Gdx.graphics.getWidth() / 2, -victory.getHeight() / 2 + 50 * HW4.SCALE + Gdx.graphics.getHeight() / 2); gameEnd.begin(); victory.draw(gameEnd); gameEnd.end(); if (rs.getStage() == null) stage.addActor(rs); }
public void initCancelButton() { // Cancel Button cancelButtonHelper = new ButtonHelper("menu/save-score-popup/cancel-button.png", 71, 71, 0, 0, 0, 71, game); cancelButton = cancelButtonHelper.getButton(); cancelButton.setPosition( (dialogSprite.getX() + dialogSprite.getWidth() - (cancelButton.getWidth() / 2) - 15), dialogSprite.getY() + dialogSprite.getHeight() - cancelButton.getHeight() + 15); }
public void update(float dt, OrthographicCamera cam) { stage.act(dt); if (Core.persistentAssets.update() && !assetsLoaded) { GameSave.save(); assetsLoaded = true; layout = new Table(Core.persistentAssets.get("skins/uiskin.json", Skin.class)); layout.setFillParent(true); layout.center().bottom(); pressBtn = new Label( "Press any key to continue", Core.persistentAssets.get("skins/uiskin.json", Skin.class)); layout.add(pressBtn).padBottom(40); layout.debug(); stage.addActor(layout); stage.addListener( new InputListener() { public boolean keyUp(InputEvent event, int keycode) { gsm.setState(GameStateManager.MENU); return false; } public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gsm.setState(GameStateManager.MENU); } }); } if (Core.persistentAssets.isLoaded("images/main-menu/background.jpg")) { if (!bgLoaded) { bgLoaded = true; bg = new Sprite(Core.persistentAssets.get("images/main-menu/background.jpg", Texture.class)); float[] size = ImageUtils.minimalStretch(bg.getWidth(), bg.getHeight(), Core.WIDTH, Core.HEIGHT); bg.setSize(size[0], size[1]); bg.setPosition(size[2], size[3]); } bgOpacity += bgOpacityModifier * dt; bgOpacity = bgOpacity > 1 ? 1 : bgOpacity; } }
public void draw(SpriteBatch batch, float parentAlpha) { stateTime += Gdx.graphics.getDeltaTime(); Sprite toRender = currentAnimation.getKeyFrame(stateTime); // -1 to account for the sword below his feet toRender.setPosition(getX(), getY() - 1); toRender.setOrigin( toRender.getX() + toRender.getWidth(), toRender.getY() + toRender.getHeight()); toRender.setRotation(getRotation()); setSize(toRender.getWidth(), toRender.getHeight()); setOrigin(toRender.getOriginX(), toRender.getOriginY()); toRender.draw(batch); if (TheLoveOfRice.DRAW_DEBUG) { drawDebug(batch); } }
@Override public void create() { batch = new SpriteBatch(); img = new Texture("scale.png"); sprite = new Sprite(img); sprite.setPosition( Gdx.graphics.getWidth() / 2 - sprite.getWidth() / 2, Gdx.graphics.getHeight() / 2 - sprite.getHeight() / 2); Gdx.input.setInputProcessor(this); }
@Override public void draw(SpriteBatch batch, float parentAlpha) { super.draw(batch, parentAlpha); Vector2 worldPos = getPosition(); sprite.setPosition(worldPos.x - (sprite.getWidth() / 2), worldPos.y - sprite.getHeight() / 2); sprite.setRotation(getRotation()); sprite.draw(batch); }
/** * An Entity with a square physics Body. * * @param sprite the sprite for this * @param world the physics world that is in * @param mass the mass of this in grams * @param x the x ordinate of this in pixels * @param y the y ordinate of this in pixels */ public SpriteEntity(float scale, Sprite sprite, World world, float mass, float x, float y) { this( scale, sprite, DEFAULT_FRICTION, world, mass, x, y, sprite.getWidth(), sprite.getHeight(), IS_STATIC_DEFAULT); }
/** * An Entity with a square physics Body. * * @param sprite the sprite for this * @param friction the coefficient of friction for this * @param world the physics world that is in * @param mass the mass of this in grams * @param x the x ordinate of this in pixels * @param y the y ordinate of this in pixels */ public SpriteEntity(Sprite sprite, float friction, World world, float mass, float x, float y) { this( 1F, sprite, friction, world, mass, x, y, sprite.getWidth(), sprite.getHeight(), IS_STATIC_DEFAULT); }
public void initDialogBG() { dialogBGPath = "menu/save-score-popup/bg.png"; // Dialog Texture dialogTexture = game.assetManager.getTexture(dialogBGPath); dialogSprite = new Sprite(dialogTexture); dialogSprite.setSize(536, 286); dialogSprite.setPosition( (stage.getWidth() / 2) - (dialogSprite.getWidth() / 2), (stage.getHeight() / 2) - (dialogSprite.getHeight() / 2)); }
/** * An Entity with a square physics Body. * * @param sprite the sprite for this * @param world the physics world that is in * @param mass the mass of this in grams * @param x the x ordinate of this in pixels * @param y the y ordinate of this in pixels * @param isStatic if this is capable of having motion */ public SpriteEntity(Sprite sprite, World world, float mass, float x, float y, boolean isStatic) { this( 1F, sprite, DEFAULT_FRICTION, world, mass, x, y, sprite.getWidth(), sprite.getHeight(), isStatic); }
/** * Constructs a new Entity * * @param texture the texture to display with the Entity * @param vel the initial velocity of the Entity */ public Entity(TextureRegion texture, Vector2 vel, float rotation) { sprite = new Sprite(texture); Vector2 size = new Vector2(sprite.getWidth() / 2, sprite.getHeight() / 2); sprite.setOrigin(size.x, size.y); entities.add(this); sprite.rotate(rotation); maxSize = size.len(); velocity = vel; id = objCount++; initVelocity = vel; initRotation = rotation; initPos = new Vector2(0, 0); }
public void renderLoading(float delta) { Gdx.gl.glClearColor(0, 0, 0, wrapper.getF()); stateTime += delta; Sprite frameSprite = new Sprite(loadingAnim().getKeyFrame(stateTime, true)); loadingBatch.begin(); frameSprite.setColor(wrapper.getF(), wrapper.getF(), wrapper.getF(), wrapper.getF()); // frameSprite.setSize(Gdx.graphics.getHeight(), Gdx.graphics.getHeight()*ratio); frameSprite.setPosition( (Gdx.graphics.getWidth() / 2) - (frameSprite.getWidth() / 2), (Gdx.graphics.getHeight() / 2) - (frameSprite.getHeight() / 2)); frameSprite.draw(loadingBatch, wrapper.getF()); loadingBatch.end(); }
/** * An Entity with a square physics Body. * * @param sprite the sprite for this * @param friction the coefficient of friction for this * @param world the physics world that is in * @param mass the mass of this in grams * @param x the x ordinate of this in pixels * @param y the y ordinate of this in pixels * @param isStatic if this is capable of having motion */ public SpriteEntity( Sprite sprite, float friction, World world, float mass, float x, float y, boolean isStatic) { this( 1F, sprite, friction, DEFAULT_RESTITUTION, world, mass, x, y, sprite.getWidth(), sprite.getHeight(), isStatic, CAN_ROTATE_DEFAULT); }
public GameLoadingScreen(StrategyGame inGame) { this.game = inGame; this.font = game.font; this.batch = game.batch; stage = new Stage(new ScreenViewport()); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Texture tex = new Texture(Gdx.files.internal("ui/game_loading.png")); background = new Sprite(tex); background.scale(1.0f); background.setPosition( (Gdx.graphics.getWidth() - background.getWidth()) / 2, (Gdx.graphics.getHeight() - background.getHeight()) / 2); }
@Override public void apply(Entity entity) { String spriteId = parameters.get("spriteId"); // default world scale, considering viewport 800f float worldScale = 0.015625f; Float x = parameters.get("x"); Float y = parameters.get("y"); Float speed = parameters.get("speed"); Integer layer = parameters.get("layer"); Sprite sprite = resourceManager.getResourceValue(spriteId); if (sprite == null) throw new RuntimeException( "Failed to instantiate static sprite, " + spriteId + " not found."); entity.setGroup(Groups.Clouds); // SpriteUtils.resize(sprite, worldWidth); final float cloudSize = 2f; float width = sprite.getWidth() * worldScale * cloudSize; float height = sprite.getHeight() * worldScale * cloudSize; SpriteComponent spriteComponent = new SpriteComponent(sprite); spriteComponent.getColor().set(1f, 1f, 1f, 0f); Synchronizers.transition( spriteComponent.getColor(), Transitions.transitionBuilder().start(new Color(1f, 1f, 1f, 0f)).end(Color.WHITE).time(1f)); entity.addComponent(new SpatialComponent(new SpatialImpl(x, y, width, height, 0f))); entity.addComponent(new PreviousStateSpatialComponent()); entity.addComponent(spriteComponent); entity.addComponent(new RenderableComponent(layer)); entity.addComponent(new BoundsComponent(new Rectangle(0f, 0f, width, height))); entity.addComponent(new MovementComponent(new Vector2(speed, 0f), 0f)); }