// resets rotation matrix, rotates to the new angle, moves image to center of screen and draws it public void draw(Canvas canvas) { matrix.reset(); matrix.postRotate( angle, animation.getImage().getWidth() / 2, animation.getImage().getHeight() / 2); matrix.postTranslate(x, y); canvas.drawBitmap(animation.getImage(), matrix, null); }
public void frameTest() { Image TestImage; Image TestImage2; TestImage = loadImage("images/Tank.jpg"); TestImage2 = loadImage("images/Tank.jpg"); Animation AnimTest = new Animation(); AnimTest.addFrame(TestImage, 200); Animation AnimTest2 = new Animation(); AnimTest2.addFrame(TestImage2, 500); System.out.println(AnimTest.getImage()); System.out.println(AnimTest2.getImage()); }
public void draw(Graphics2D g) { tX = mp.getX(); tY = mp.getY(); if (reverse) { if (factingRight) { g.drawImage( animation.getImage(), (int) (tX + x - width / 2), (int) (tY + y + height / 2), width, -height, null); } else { g.drawImage( animation.getImage(), (int) (tX + x + width / 2), (int) (tY + y + height / 2), -width, -height, null); } } else { if (factingRight) { g.drawImage( animation.getImage(), (int) (tX + x - width / 2), (int) (tY + y - height / 2), null); } else { g.drawImage( animation.getImage(), (int) (tX + x + width / 2), (int) (tY + y - height / 2), -width, height, null); } } // health if (health > 4) { g.drawImage(healths[0], 30, 30, null); } else { if (health > 2) { g.drawImage(healths[1], 30, 30, null); } else { if (health > 0) { g.drawImage(healths[2], 30, 30, null); } } } }
public void draw(Graphics g) { // draw background g.drawImage(bgImage, 0, 0, null); // draw image g.drawImage(anim.getImage(), 0, 0, null); }
public void draw(SpriteBatch g) { if (!gs.entities.contains(this) && !(this instanceof Player)) { gs.world.destroyBody(body); return; } /* if(bmf == null)bmf = new BitmapFont(); if(turnme)bmf.draw(g, String.valueOf(diff), 10, 100); bmf.draw(g,cleanCoords(new Vector2 ((float) (body.getAngle() - Math.PI / 2) , gs.gTheta)), 20, 80); bmf.draw(g,cleanCoords(body.getLinearVelocity()),20,20); bmf.draw(g, "Grounded: " + String.valueOf(((PlayState)gs).isPlayerGrounded(1/60f)),20,40); bmf.draw(g,"Turnme: " + String.valueOf(turnme),20,60); bmf.setColor(Color.WHITE);*/ float flip = 1; float hshift = pwidth / 2; float vshift = 0; if (getGravityDir() == null) System.out.println("throw a dance party"); switch (getGravityDir()) { case Up: flip = facingRight ? 1 : -1; hshift = facingRight ? pwidth / 2 : -pwidth / 2; break; case Down: flip = facingRight ? -1 : 1; hshift = facingRight ? 3f / 2f * pwidth : pwidth / 2; break; case Left: flip = facingRight ? 1 : -1; hshift = facingRight ? pwidth / 2 : pwidth / 2; vshift = facingRight ? 0 : pwidth; break; case Right: flip = facingRight ? -1 : 1; hshift = facingRight ? pwidth / 2 : pwidth / 2; vshift = facingRight ? -pwidth : 0; break; } float mTheta = MathUtils.dirToAngle(getGravityDir()) * 180f / (float) Math.PI - 90; g.setProjectionMatrix(gs.cam.combined); g.draw( anim.getImage(), body.getPosition().x - hshift, body.getPosition().y - pheight / 2 + vshift, pwidth / 2, pheight / 2, flip * pwidth, pheight, 1f, 1f, mTheta); // System.out.println(gs.getGravityDirection().name()); }
/** Gets this Sprite's current image. */ public Image getImage() { return anim.getImage(); }
/** Gets this Sprite's height, based on the size of the current image. */ public int getHeight() { return anim.getImage().getHeight(null); }
/** Gets this Sprite's width, based on the size of the current image. */ public int getWidth() { return anim.getImage().getWidth(null); }
public Image getImage() { return currAnimation.getImage(); }
@Override protected void doDraw(Graphics2D g, int x, int y, int width, int height) { x -= currAnimation.getRefPixelX(); y -= currAnimation.getRefPixelY(); g.drawImage(currAnimation.getImage(), x, y, (x + width), (y + height), 0, 0, width, height, null); }
public void draw(Canvas canvas) { canvas.drawBitmap(animation.getImage(), x, y, null); }
@Override public void update(float deltaTime) { Graphics g = game.getGraphics(); menu.update(14); List<TouchEvent> touchEvents = game.getInput().getTouchEvents(); // WEIRD ANDROID GLITCH: plays halfsec of theme on boot unless I do this: if (loaded) { Assets.theme.play(); } if (menu.getImage() == Assets.menu1) loaded = true; int len = touchEvents.size(); // System.out.println(idle); // System.out.println(instr); for (int i = 0; i < len; i++) { TouchEvent event = touchEvents.get(i); if (event.x < game.getLoadWidth() / 2 && event.y > game.getLoadHeight() * .87 && instr == 0 && event.type == TouchEvent.TOUCH_UP && loaded) { // START GAME Assets.click.play(100); Assets.theme.stop(); Assets.coug1 = g.newImage("coug1b.png", ImageFormat.RGB565); Assets.coug2 = g.newImage("coug2b.png", ImageFormat.RGB565); Assets.coug3 = g.newImage("coug3b.png", ImageFormat.RGB565); Assets.coug4 = g.newImage("coug4b.png", ImageFormat.RGB565); Assets.coug5 = g.newImage("coug5b.png", ImageFormat.RGB565); Assets.mFace = g.newImage("face2PIXX.gif", ImageFormat.RGB565); Assets.mFaced = g.newImage("facedeathPIX3.gif", ImageFormat.RGB565); Assets.hadronOne = g.newImage("hadron.png", ImageFormat.RGB565); game.setScreen(new GameScreen(game)); } if (event.x > game.getLoadWidth() / 2 && event.y > game.getLoadHeight() * .79 && event.y < game.getLoadHeight() * .9 && instr == 0 && event.type == TouchEvent.TOUCH_UP && loaded) { Assets.click2.play(100); Assets.coug1 = g.newImage("coug1b.png", ImageFormat.RGB565); Assets.coug2 = g.newImage("coug2b.png", ImageFormat.RGB565); Assets.coug3 = g.newImage("coug3b.png", ImageFormat.RGB565); Assets.coug4 = g.newImage("coug4b.png", ImageFormat.RGB565); Assets.coug5 = g.newImage("coug5b.png", ImageFormat.RGB565); Assets.mFace = g.newImage("face2PIXX.gif", ImageFormat.RGB565); Assets.mFaced = g.newImage("facedeathPIX3.gif", ImageFormat.RGB565); game.setScreen(new Tutorial(game)); } if (event.x > game.getLoadWidth() * .69 && event.y < game.getLoadHeight() * .21 && event.type == TouchEvent.TOUCH_UP && instr != 0 && loaded) { Assets.click2.play(100); instr++; } if (event.x > game.getLoadWidth() * .53 && event.y > game.getLoadHeight() * .91 && instr == 0 && event.type == TouchEvent.TOUCH_UP && loaded) { android.os.Process.killProcess(android.os.Process.myPid()); } } }
@Override public void paint(float deltaTime) { Graphics g = game.getGraphics(); // g.drawImage(Assets.menu, 0, 0); g.drawImage(menu.getImage(), 0, 0); if (instr == 1) { Assets.instr1 = g.newImage("instr1.png", ImageFormat.RGB565); if (Assets.instr2 != null) Assets.instr2.getBitmap().recycle(); g.drawImage(Assets.instr1, 0, 0); } if (instr == 2) { Assets.instr1.getBitmap().recycle(); Assets.instr2 = g.newImage("instr2.png", ImageFormat.RGB565); if (Assets.instr3 != null) Assets.instr3.getBitmap().recycle(); g.drawImage(Assets.instr2, 0, 0); } if (instr == 3) { Assets.instr3 = g.newImage("instr3.png", ImageFormat.RGB565); Assets.instr2.getBitmap().recycle(); if (Assets.instr4 != null) Assets.instr4.getBitmap().recycle(); g.drawImage(Assets.instr3, 0, 0); } if (instr == 4) { Assets.instr4 = g.newImage("instr4.png", ImageFormat.RGB565); Assets.instr3.getBitmap().recycle(); if (Assets.instr5 != null) Assets.instr5.getBitmap().recycle(); g.drawImage(Assets.instr4, 0, 0); } if (instr == 5) { Assets.instr5 = g.newImage("instr5.png", ImageFormat.RGB565); Assets.instr4.getBitmap().recycle(); if (Assets.instr6 != null) Assets.instr6.getBitmap().recycle(); g.drawImage(Assets.instr5, 0, 0); } if (instr == 6) { Assets.instr6 = g.newImage("instr6.png", ImageFormat.RGB565); Assets.instr5.getBitmap().recycle(); if (Assets.instr7 != null) Assets.instr7.getBitmap().recycle(); g.drawImage(Assets.instr6, 0, 0); } if (instr == 7) { Assets.instr7 = g.newImage("instr7.png", ImageFormat.RGB565); Assets.instr6.getBitmap().recycle(); if (Assets.instr8 != null) Assets.instr8.getBitmap().recycle(); g.drawImage(Assets.instr7, 0, 0); } if (instr == 8) { Assets.instr8 = g.newImage("instr8.png", ImageFormat.RGB565); Assets.instr7.getBitmap().recycle(); if (Assets.instr9 != null) Assets.instr9.getBitmap().recycle(); g.drawImage(Assets.instr8, 0, 0); } if (instr == 9) { Assets.instr9 = g.newImage("instr9.png", ImageFormat.RGB565); Assets.instr8.getBitmap().recycle(); if (Assets.instrPause != null) Assets.instrPause.getBitmap().recycle(); g.drawImage(Assets.instr9, 0, 0); } if (instr == 10) { Assets.instrPause = g.newImage("instrPAUSE2.png", ImageFormat.RGB565); Assets.instr9.getBitmap().recycle(); g.drawRect(0, 0, 805, 1205, Color.BLACK); g.drawImage(Assets.instrPause, 0, 0); } if (instr == 11) { Assets.instrPause.getBitmap().recycle(); instr = 0; } }
public void draw(Graphics2D g) { g.drawImage( animation.getImage(), (int) x - width / 2, (int) y - height / 2, width, height, null); }