Java Code Examples for com.badlogic.gdx.graphics.g2d.TextureRegion#split()
The following examples show how to use
com.badlogic.gdx.graphics.g2d.TextureRegion#split() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientBomb.java From killingspree with MIT License | 6 votes |
public ClientBomb(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; sprite = new Sprite(AssetLoader.instance.getTexture("sprites/bomb.png")); sprite.setSize(ServerBomb.RADIUS + 5, ServerBomb.RADIUS + 5); sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2); sprite.setPosition(x - sprite.getWidth() / 2, y - sprite.getHeight() / 2); deadTimer = 0f; Texture explodeTexture = AssetLoader.instance. getTexture("sprites/explosion.png"); explode = new Animation(0.03f, TextureRegion.split(explodeTexture, explodeTexture.getWidth()/7, explodeTexture.getHeight())[0]); }
Example 2
Source File: EntityAnimation.java From Norii with Apache License 2.0 | 5 votes |
private TextureRegion[][] initVariables() { final Texture texture = Utility.getTextureAsset(spritePath); final TextureRegion[][] textureFrames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT); walkDownFrames = new Array<TextureRegion>(ANIMATIONFRAMES); walkLeftFrames = new Array<TextureRegion>(ANIMATIONFRAMES); walkRightFrames = new Array<TextureRegion>(ANIMATIONFRAMES); walkUpFrames = new Array<TextureRegion>(ANIMATIONFRAMES); return textureFrames; }
Example 3
Source File: MainGameScreen.java From libgdx-2d-tutorial with MIT License | 5 votes |
public MainGameScreen (SpaceGame game) { this.game = game; y = 15; x = SpaceGame.WIDTH / 2 - SHIP_WIDTH / 2; bullets = new ArrayList<Bullet>(); asteroids = new ArrayList<Asteroid>(); explosions = new ArrayList<Explosion>(); scoreFont = new BitmapFont(Gdx.files.internal("fonts/score.fnt")); playerRect = new CollisionRect(0, 0, SHIP_WIDTH, SHIP_HEIGHT); blank = new Texture("blank.png"); if (SpaceGame.IS_MOBILE) controls = new Texture("controls.png"); score = 0; random = new Random(); asteroidSpawnTimer = random.nextFloat() * (MAX_ASTEROID_SPAWN_TIME - MIN_ASTEROID_SPAWN_TIME) + MIN_ASTEROID_SPAWN_TIME; shootTimer = 0; roll = 2; rollTimer = 0; rolls = new Animation[5]; TextureRegion[][] rollSpriteSheet = TextureRegion.split(new Texture("ship.png"), SHIP_WIDTH_PIXEL, SHIP_HEIGHT_PIXEL); rolls[0] = new Animation(SHIP_ANIMATION_SPEED, rollSpriteSheet[2]);//All left rolls[1] = new Animation(SHIP_ANIMATION_SPEED, rollSpriteSheet[1]); rolls[2] = new Animation(SHIP_ANIMATION_SPEED, rollSpriteSheet[0]);//No tilt rolls[3] = new Animation(SHIP_ANIMATION_SPEED, rollSpriteSheet[3]); rolls[4] = new Animation(SHIP_ANIMATION_SPEED, rollSpriteSheet[4]);//Right game.scrollingBackground.setSpeedFixed(false); }
Example 4
Source File: LabelAtlas.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
/** * @param tr 数字材质 * @param tileWidth 数字宽度 * @param tileHeight 数字高度 * @param startCharMap 起始字符,例如:0123456789*+-x * 这里必须填写数字的全部字符,并且顺序一致.否则会显示错乱 * @param stringValue 显示内容,例如:89/50 */ public LabelAtlas(TextureRegion tr, int tileWidth, int tileHeight, String startCharMap, String stringValue) { this.tileWidth = tileWidth; this.tileHeight = tileHeight; TextureRegion[][] arr = tr.split(tileWidth, tileHeight); trs = arr[0]; if (startCharMap == null) { startCharMap = "0"; // 默认值 } this.chars = startCharMap.toCharArray(); setText(stringValue); }
Example 5
Source File: ClientFrog.java From killingspree with MIT License | 5 votes |
public ClientFrog(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/frog.png"); sprite = new Sprite(texture); walk = new Animation(0.25f, TextureRegion.split(texture, texture.getWidth()/2, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); sprite.setSize(ServerFrog.WIDTH + 5f, ServerFrog.HEIGHT + 5f); }
Example 6
Source File: ClientPlayer.java From killingspree with MIT License | 5 votes |
public ClientPlayer(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/player.png"); sprite = new Sprite(texture); gunSprite = new Sprite(AssetLoader.instance.getTexture("sprites/arrow.png")); gunSprite.setOrigin(gunSprite.getWidth()/2, gunSprite.getHeight()/2); walk = new Animation(0.05f, TextureRegion.split(texture, texture.getWidth()/10, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); walkDuration = 0; gunSprite.setSize(40, 6); gunSprite.setOrigin(gunSprite.getWidth()/2, gunSprite.getHeight()/2); gunSprite.setAlpha(0.7f); }
Example 7
Source File: ClientTestPlayer.java From killingspree with MIT License | 5 votes |
public ClientTestPlayer(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/explosion.png"); sprite = new Sprite(texture); walk = new Animation(0.05f, TextureRegion.split(texture, texture.getWidth()/7, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); walkDuration = 0; }
Example 8
Source File: ClientBlob.java From killingspree with MIT License | 5 votes |
public ClientBlob(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/blob.png"); sprite = new Sprite(texture); walk = new Animation(0.25f, TextureRegion.split(texture, texture.getWidth()/2, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); sprite.setSize(ServerBlob.WIDTH + 5f, ServerBlob.HEIGHT); deadTimer = 2f; }
Example 9
Source File: ClientFly.java From killingspree with MIT License | 5 votes |
public ClientFly(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/fly.png"); sprite = new Sprite(texture); walk = new Animation(0.25f, TextureRegion.split(texture, texture.getWidth()/2, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); sprite.setSize(ServerBlob.WIDTH + 5f, ServerFly.HEIGHT); }
Example 10
Source File: EntityAnimation.java From Norii with Apache License 2.0 | 4 votes |
private void loadSprite() { final Texture texture = Utility.getTextureAsset(spritePath); final TextureRegion[][] textureFrames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT); frameSprite = new Sprite(textureFrames[0][0].getTexture(), 0, 0, FRAME_WIDTH, FRAME_HEIGHT); currentFrame = textureFrames[0][0]; }
Example 11
Source File: LR2PlaySkinLoader.java From beatoraja with GNU General Public License v3.0 | 4 votes |
private static void addJudgeDetail(Skin skin, int[] values, float srcw, float dstw, float srch, float dsth, int side) { Texture tex = new Texture("skin/default/judgedetail.png"); final float dw = dstw / 1280f; final float dh = dsth / 720f; final int[] JUDGE_TIMER = { TIMER_JUDGE_1P, TIMER_JUDGE_2P, TIMER_JUDGE_3P }; final int[] OPTION_EARLY = { OPTION_1P_EARLY, OPTION_2P_EARLY, OPTION_3P_EARLY }; final int[] OPTION_LATE = { OPTION_1P_LATE, OPTION_2P_LATE, OPTION_3P_LATE }; final int[] VALUE_JUDGE_DURATION = { VALUE_JUDGE_1P_DURATION, VALUE_JUDGE_2P_DURATION, VALUE_JUDGE_3P_DURATION }; final int[] OPTION_PERFECT = { OPTION_1P_PERFECT, OPTION_2P_PERFECT, OPTION_3P_PERFECT }; final int[] OFFSET_JUDGE = { OFFSET_JUDGE_1P, OFFSET_JUDGE_2P, OFFSET_JUDGE_3P }; final int[] OFFSET_JUDGE_DETAIL = { OFFSET_JUDGEDETAIL_1P, OFFSET_JUDGEDETAIL_2P, OFFSET_JUDGEDETAIL_3P }; SkinImage early = new SkinImage(new TextureRegion(tex, 0, 0, 50,20)); early.setDestination(0, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 40 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1998, 0, OPTION_EARLY[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); early.setDestination(500, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 40 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1998, 0, OPTION_EARLY[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); skin.add(early); SkinImage late = new SkinImage(new TextureRegion(tex, 50, 0, 50,20)); late.setDestination(0, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 40 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1998, 0, OPTION_LATE[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); late.setDestination(500, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 40 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1998, 0, OPTION_LATE[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); skin.add(late); TextureRegion[][] images = TextureRegion.split(tex, 10, 20); SkinNumber num = new SkinNumber(new TextureRegion[][] { images[1] }, new TextureRegion[][] { images[2] }, 0, 0, 4, 0, values[15], VALUE_JUDGE_DURATION[side]); num.setAlign(values[12]); num.setDestination(0, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 8 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1999, 0, OPTION_PERFECT[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); num.setDestination(500, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 8 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1999, 0, OPTION_PERFECT[side], new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); skin.add(num); SkinNumber num2 = new SkinNumber(new TextureRegion[][] { images[3] }, new TextureRegion[][] { images[4] }, 0, 0, 4, 0, values[15], VALUE_JUDGE_DURATION[side]); num2.setAlign(values[12]); num2.setDestination(0, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 8 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1999, 0, -(OPTION_PERFECT[side]), new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); num2.setDestination(500, (values[3] + values[5] / 2) * dstw / srcw, dsth - (values[4] - 5) * dsth / srch, 8 * dw, 16 * dh, 0, 255, 255, 255, 255, 0, 0, 0, 0, -1, JUDGE_TIMER[side], 1999, 0, -(OPTION_PERFECT[side]), new int[]{OFFSET_JUDGE_DETAIL[side], OFFSET_LIFT}); skin.add(num2); }