List of usage examples for com.badlogic.gdx.graphics.g2d Sprite Sprite
public Sprite(Sprite sprite)
From source file:actors.Archer.java
public Archer(float hlth, float dmg, float x, float y, float arrowTmr, Stage stg, int lvl, int pth) { notmoving = false;// w w w .j a v a2s . c o m health = hlth; damage = dmg; stage = stg; level = lvl; path = pth; arrowTimer = arrowTmr; this.setName("archer"); texture = new Texture("archer.png"); sprite = new Sprite(texture); sprite.setScale(0.65f); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); velocity = 50; assignMovement(x, y); /* init = new MoveToAction(); init.setPosition(x, y); ms = new MoveToAction(); ms.setPosition(100f,375f); ma1 = new MoveToAction(); ma1.setPosition(315f,375f); ma1.setDuration(((315-100 )/velocity)); ma2 = new MoveToAction(); ma2.setPosition(315f, 180f); ma2.setDuration((375-180)/velocity); ma3 = new MoveToAction(); ma3.setPosition(510f, 180f); ma3.setDuration((510-315)/velocity); ma4 = new MoveToAction(); ma4.setPosition(510f, 570f); ma4.setDuration((570-180)/velocity); ma5 = new MoveToAction(); ma5.setPosition(680f, 570f); ma5.setDuration((680-510)/velocity); ma6 = new MoveToAction(); ma6.setPosition(680f, 375f); ma6.setDuration((570-375)/velocity); ma7 = new MoveToAction(); ma7.setPosition(1000f, 375f); ma7.setDuration((1000-680)/velocity); SequenceAction sa1 = new SequenceAction(ms, ma1, ma2, ma3, ma4); SequenceAction sa2 = new SequenceAction(ma5, ma6, ma7); SequenceAction sa3 = new SequenceAction(ma1, ma2, ma3, ma4); SequenceAction sa4 = new SequenceAction(ma2, ma3, ma4); SequenceAction sa5 = new SequenceAction(ma3, ma4, ma5, ma6, ma7); SequenceAction sa6 = new SequenceAction(init, ma4, ma5, ma6, ma7); SequenceAction sa7 = new SequenceAction(init, ma5, ma6, ma7); SequenceAction sa8 = new SequenceAction(init, ma6, ma7); SequenceAction csa1 = new SequenceAction(sa1, sa2); SequenceAction csa2 = new SequenceAction(init, sa3, sa2); SequenceAction csa3 = new SequenceAction(init, sa4, sa2); SequenceAction csa4 = new SequenceAction(init, sa5); if((x==100)&&(y==375)) this.addAction(csa1); else if((y==375)&&(x<315)) { ma1.setDuration((315-x)/velocity); sa3 = new SequenceAction(ma1, ma2, ma3, ma4); csa2 = new SequenceAction(init, sa3, sa2); this.addAction(csa2); } else if((x==315)&&(y!=180)) { ma2.setDuration((y-180)/velocity); sa4 = new SequenceAction(ma2, ma3, ma4); csa3 = new SequenceAction(init, sa4, sa2); this.addAction(csa3); } else if((y==180)&&(x!=510)) { ma3.setDuration((510-x)/velocity); sa5 = new SequenceAction(ma3, ma4, ma5, ma6, ma7); csa4 = new SequenceAction(init, sa5); this.addAction(csa4); } else if((x==510)&&(y!=570)) { ma4.setDuration((570-y)/velocity); sa6 = new SequenceAction(init, ma4, ma5, ma6, ma7); this.addAction(sa6); } else if((y==570)&&(x!=680)) { ma5.setDuration((680-x)/velocity); sa7 = new SequenceAction(init, ma5, ma6, ma7); this.addAction(sa7); } else if((x==680)&&(y!=375)) { ma6.setDuration((y-375)/velocity); sa8 = new SequenceAction(init, ma6, ma7); this.addAction(sa8); } else if((y==375)&&(x>315)) { ma7.setDuration((1000-x)/velocity); SequenceAction sa9 = new SequenceAction(init, ma7); this.addAction(sa9); } */ }
From source file:actors.Arrow.java
public Arrow(float startX, float startY, float destX, float destY) { this.setName("arrow"); texture = new Texture("arrow.png"); sprite = new Sprite(texture); sprite.setScale(0.1f);//w ww . jav a 2 s . c om angle = (float) Math.toDegrees(atan((destY - startY) / (destX - startX))); System.out.println(String.valueOf(angle)); sprite.setOriginCenter(); sprite.rotate(angle + 270); //sprite.setRotation(angle); velocity = 300; init = new MoveToAction(); init.setPosition(startX, startY); distSquared = ((startX - destX) * (startX - destX) + (startY - destY) * (startY - destY)); shoot = new MoveToAction(); shoot.setPosition(destX, destY); shoot.setDuration((float) (sqrt(distSquared) / velocity)); moveOff = new MoveToAction(); moveOff.setPosition(-100f, -100f); SequenceAction sa = new SequenceAction(init, shoot, moveOff); this.addAction(sa); }
From source file:actors.BasicSkel.java
public BasicSkel(float hlth, float dmg, float x, float y, int lvl, int pth, Stage stg, PlayScreen scrn) { this.setName("skeleton"); level = lvl;/* w ww.j av a 2 s.c o m*/ path = pth; stage = stg; screen = scrn; health = hlth; damage = dmg; slowTimer = -1; slowed = false; reset = false; poisoned = false; notmoving = false; if (damage < 220) texture = new Texture("skelsword1.png"); if (damage < 240 && damage >= 220) texture = new Texture("skelsword2.png"); if (damage >= 240) texture = new Texture("skelsword3.png"); sprite = new Sprite(texture); sprite.setScale(0.65f); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); fireEffect = new ParticleEffect(); fireEffect.load(Gdx.files.internal("fire"), Gdx.files.internal("")); fireEffect.getEmitters().first().setPosition(getX(), getY()); fireballSound = Gdx.audio.newSound(Gdx.files.internal("fireball.wav")); iceEffect = new ParticleEffect(); iceEffect.load(Gdx.files.internal("ice"), Gdx.files.internal("")); iceEffect.getEmitters().first().setPosition(getX(), getY()); poisonEffect = new ParticleEffect(); poisonEffect.load(Gdx.files.internal("poison"), Gdx.files.internal("")); poisonEffect.getEmitters().first().setPosition(getX(), getY()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); ColorAction red = new ColorAction(); red.setEndColor(Color.RED); red.setDuration(1f); MoveToAction moveOff = new MoveToAction(); moveOff.setPosition(-100, -100); kill = new SequenceAction(red, moveOff); this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (health != 100000 && abs(screen.player.getX() - getX()) < screen.playerRange && abs(screen.player.getY() - getY()) < screen.playerRange) { if (screen.playerSpell == 1) { health -= screen.playerDamage; stage.addActor( new Fireball(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); fireEffect.start(); } if (screen.playerSpell == 2) { health -= screen.playerDamage * 0.75; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); iceEffect.start(); slowTimer = 3; if (health >= 0) slowed = true; } if (screen.playerSpell == 3) { poisoned = true; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); poisonEffect.start(); } } if (health <= 0) { poisoned = false; setName("dead"); health = 100000; clearActions(); addAction(kill); screen.skeletonDeath.play(1.0f); screen.addGold(5); } } }); velocity = 70; //Rectangle body = new Rectangle(getX(), getY(), getWidth(), getHeight()); //ScaleByAction sba = new ScaleByAction(); //sba.setAmount(0.25f); assignMovement(x, y); }
From source file:actors.Castle.java
public Castle(float hlth, float damage, float x, float y, Stage stage) { this.setName("castle"); texture = new Texture("castle.png"); health = hlth;/* w ww. j a v a 2s . c o m*/ arrowTimer = 3; sprite = new Sprite(texture); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); velocity = 70; ms = new MoveToAction(); ms.setPosition(x, y); // ms.setPosition(35f,370f); Castle.this.addAction(ms); }
From source file:actors.Fireball.java
public Fireball(float startX, float startY, float destX, float destY) { this.setName("fireball"); texture = new Texture("firearrow.png"); sprite = new Sprite(texture); sprite.setScale(0.5f);//w ww. j a v a 2 s .co m angle = (float) Math.toDegrees(atan((destY - startY) / (destX - startX))); System.out.println(String.valueOf(angle)); sprite.setOriginCenter(); sprite.rotate(angle + 270); //sprite.setRotation(angle); velocity = 500; init = new MoveToAction(); init.setPosition(startX, startY); distSquared = ((startX - destX) * (startX - destX) + (startY - destY) * (startY - destY)); shoot = new MoveToAction(); shoot.setPosition(destX, destY); shoot.setDuration((float) (sqrt(distSquared) / velocity)); moveOff = new MoveToAction(); moveOff.setPosition(-100f, -100f); SequenceAction sa = new SequenceAction(init, shoot, moveOff); this.addAction(sa); }
From source file:actors.Footman.java
public Footman(float hlth, float dmg, float x, float y, int lvl, int pth) { this.setName("footman"); damage = dmg;//from w w w.j ava2 s . co m health = hlth; level = lvl; path = pth; notmoving = false; if (damage < 400) texture = new Texture("footman0.png"); if (damage < 450 && damage >= 400) texture = new Texture("footman1.png"); if (damage < 600 && damage >= 450) texture = new Texture("footman2.png"); if (damage < 1000 && damage >= 600) texture = new Texture("champion.png"); if (damage >= 1000) texture = new Texture("footman3.png"); sprite = new Sprite(texture); sprite.setScale(0.65f); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); setTouchable(Touchable.disabled); velocity = 80; inCombat = false; assignMovement(x, y); /* init = new MoveToAction(); init.setPosition(x, y); ms = new MoveToAction(); ms.setPosition(100f,375f); ma1 = new MoveToAction(); ma1.setPosition(315f,375f); ma1.setDuration(((315-100 )/velocity)); ma2 = new MoveToAction(); ma2.setPosition(315f, 180f); ma2.setDuration((375-180)/velocity); ma3 = new MoveToAction(); ma3.setPosition(510f, 180f); ma3.setDuration((510-315)/velocity); ma4 = new MoveToAction(); ma4.setPosition(510f, 570f); ma4.setDuration((570-180)/velocity); ma5 = new MoveToAction(); ma5.setPosition(680f, 570f); ma5.setDuration((680-510)/velocity); ma6 = new MoveToAction(); ma6.setPosition(680f, 375f); ma6.setDuration((570-375)/velocity); ma7 = new MoveToAction(); ma7.setPosition(1000f, 375f); ma7.setDuration((1000-680)/velocity); SequenceAction sa1 = new SequenceAction(ms, ma1, ma2, ma3, ma4); SequenceAction sa2 = new SequenceAction(ma5, ma6, ma7); SequenceAction sa3 = new SequenceAction(ma1, ma2, ma3, ma4); SequenceAction sa4 = new SequenceAction(ma2, ma3, ma4); SequenceAction sa5 = new SequenceAction(ma3, ma4, ma5, ma6, ma7); SequenceAction sa6 = new SequenceAction(init, ma4, ma5, ma6, ma7); SequenceAction sa7 = new SequenceAction(init, ma5, ma6, ma7); SequenceAction sa8 = new SequenceAction(init, ma6, ma7); SequenceAction csa1 = new SequenceAction(sa1, sa2); SequenceAction csa2 = new SequenceAction(init, sa3, sa2); SequenceAction csa3 = new SequenceAction(init, sa4, sa2); SequenceAction csa4 = new SequenceAction(init, sa5); if((x==100)&&(y==375)) this.addAction(csa1); else if((y==375)&&(x<315)) { ma1.setDuration((315-x)/velocity); sa3 = new SequenceAction(ma1, ma2, ma3, ma4); csa2 = new SequenceAction(init, sa3, sa2); this.addAction(csa2); } else if((x==315)&&(y!=180)) { ma2.setDuration((y-180)/velocity); sa4 = new SequenceAction(ma2, ma3, ma4); csa3 = new SequenceAction(init, sa4, sa2); this.addAction(csa3); } else if((y==180)&&(x!=510)) { ma3.setDuration((510-x)/velocity); sa5 = new SequenceAction(ma3, ma4, ma5, ma6, ma7); csa4 = new SequenceAction(init, sa5); this.addAction(csa4); } else if((x==510)&&(y!=570)) { ma4.setDuration((570-y)/velocity); sa6 = new SequenceAction(init, ma4, ma5, ma6, ma7); this.addAction(sa6); } else if((y==570)&&(x!=680)) { ma5.setDuration((680-x)/velocity); sa7 = new SequenceAction(init, ma5, ma6, ma7); this.addAction(sa7); } else if((x==680)&&(y!=375)) { ma6.setDuration((y-375)/velocity); sa8 = new SequenceAction(init, ma6, ma7); this.addAction(sa8); } else if((y==375)&&(x>315)) { ma7.setDuration((1000-x)/velocity); SequenceAction sa9 = new SequenceAction(init, ma7); this.addAction(sa9); } */ }
From source file:actors.IceBolt.java
public IceBolt(float startX, float startY, float destX, float destY) { this.setName("icebolt"); texture = new Texture("icearrow.png"); sprite = new Sprite(texture); sprite.setScale(0.5f);/*w w w. ja v a 2 s. c om*/ angle = (float) Math.toDegrees(atan((destY - startY) / (destX - startX))); System.out.println(String.valueOf(angle)); sprite.setOriginCenter(); sprite.rotate(angle + 270); //sprite.setRotation(angle); velocity = 500; init = new MoveToAction(); init.setPosition(startX, startY); distSquared = ((startX - destX) * (startX - destX) + (startY - destY) * (startY - destY)); shoot = new MoveToAction(); shoot.setPosition(destX, destY); shoot.setDuration((float) (sqrt(distSquared) / velocity)); moveOff = new MoveToAction(); moveOff.setPosition(-100f, -100f); SequenceAction sa = new SequenceAction(init, shoot, moveOff); this.addAction(sa); }
From source file:actors.Necromancer.java
public Necromancer(float hlth, float damage, float x, float y, Stage stage) { this.setName("necromancer"); texture = new Texture("necromancer.png"); sprite = new Sprite(texture); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); health = hlth;// w w w . j av a 2s . c om attackTimer = 2; emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); velocity = 70; ms = new MoveToAction(); ms.setPosition(x, y); // ms.setPosition(940f,375f); Necromancer.this.addAction(ms); /* int len = stage.size; for(i=0; i<len; i++){ Actor a = stageActors.get(i); if(a.getName().equals("myactor")){ //a is your Actor! break; */ }
From source file:actors.NecromancerAttack.java
public NecromancerAttack(float startX, float startY, float destX, float destY) { this.setName("necromancerbolt"); texture = new Texture("deathbolt.png"); sprite = new Sprite(texture); sprite.setScale(0.5f);/*from w w w .j a v a 2 s . co m*/ angle = (float) Math.toDegrees(atan((destY - startY) / (destX - startX))); System.out.println(String.valueOf(angle)); sprite.setOriginCenter(); sprite.rotate(angle + 270); //sprite.setRotation(angle); velocity = 500; init = new MoveToAction(); init.setPosition(startX, startY); distSquared = ((startX - destX) * (startX - destX) + (startY - destY) * (startY - destY)); shoot = new MoveToAction(); shoot.setPosition(destX, destY); shoot.setDuration((float) (sqrt(distSquared) / velocity)); moveOff = new MoveToAction(); moveOff.setPosition(-100f, -100f); SequenceAction sa = new SequenceAction(init, shoot, moveOff); this.addAction(sa); }
From source file:at.juggle.games.counting.screens.MenuScreen.java
License:Apache License
public MenuScreen(CountingGame game) { this.parentGame = game; backgroundImage = parentGame.getAssetManager().get("menu/menu_background.jpg"); menuFont = parentGame.getAssetManager().get("menu/Ravie_72.fnt"); startZaehlen = new Sprite(parentGame.getAssetManager().get("sprites/button_count.png", Texture.class)); startZaehlen.setPosition(offsetLeft, CountingGame.GAME_HEIGHT - offsetTop - buttonSize); startZaehlen.setScale(buttonSize / startZaehlen.getWidth()); startMengen = new Sprite(parentGame.getAssetManager().get("sprites/button_question.png", Texture.class)); startMengen.setPosition(offsetLeft + 3f * buttonSize / 2f, CountingGame.GAME_HEIGHT - offsetTop - buttonSize); startMengen.setScale(buttonSize / startMengen.getWidth()); for (int i = 0; i < background.length; i++) { String[] fileName = { "sprites/balloon.png", "sprites/balloonblue.png", "sprites/balloongreen.png" }; background[i] = new Balloon(TextureRegion.split( parentGame.getAssetManager().get(fileName[(int) (Math.random() * 3)], Texture.class), 128, 192)[0]);// w w w . j ava2s . c o m background[i].setPosition( CountingGame.GAME_WIDTH / 2f + ((float) (Math.random() * CountingGame.GAME_WIDTH / 2f)), -((float) (Math.random() * CountingGame.GAME_HEIGHT))); background[i].setSpeed((float) Math.random() + 0.5f); } menuFont.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); // menuFont.getData().setScale(1f); // Create camera that projects the game onto the actual screen size. cam = new OrthographicCamera(CountingGame.GAME_WIDTH, CountingGame.GAME_HEIGHT); cam.position.set(cam.viewportWidth / 2f, cam.viewportHeight / 2f, 0); cam.update(); // setting the number of ballons if we come here a second time. for (int i = 0; i < numberOfBallonsValues.length; i++) { if (numberOfBallonsValues[i] == CountingGame.numberOfBalloons) numberOfBallonsIndex = i; } batch = new SpriteBatch(); }