Facebook
From kriss, 7 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 291
  1. package dev.kris.justi.simplegame.ui;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.image.BufferedImage;
  5.  
  6. public class UIImageButton extends UIObject {
  7.  
  8.        
  9.         private BufferedImage[] images;
  10.         private ClickListener clicker;
  11.         public UIImageButton(float x, float y, int width, int height, BufferedImage[] images, ClickListener clicker) {
  12.                
  13.                 super(x, y, width, height);
  14.                 this.images=images;
  15.                 this.clicker=clicker;
  16.         }
  17.  
  18.         @Override
  19.         public void tick() {
  20.                
  21.                
  22.         }
  23.  
  24.         @Override
  25.         public void render(Graphics g) {
  26.                
  27.                 if(hovering){
  28.                         System.out.println("hovering");
  29.                         g.drawImage(images[1], (int)x,(int)y,width,height,null);
  30.                 }
  31.                 else
  32.                         g.drawImage(images[0], (int)x,(int)y,width,height,null);
  33.                
  34.         }
  35.        
  36. public void renderSetUp(Graphics g) {
  37.                
  38.                 if(hovering){
  39.                         System.out.println("hovering");
  40.                         g.drawImage(images[1], (int)x,(int)y,width,height,null);
  41.                 }
  42.                 else{
  43.                         g.drawImage(images[0], (int)x,(int)y,width,height,null);
  44.                 }
  45.                
  46.         }
  47.  
  48.        
  49.  
  50.         @Override
  51.         public void onClick() {
  52.                 clicker.onClick();
  53.                
  54.         }
  55.  
  56.         @Override
  57.         public void renderGame(Graphics g) {
  58.                 if(hovering){
  59.                         System.out.println("hovering");
  60.                         g.drawImage(images[1], (int)x,(int)y,width,height,null);
  61.                 }
  62.                 else{
  63.                         g.drawImage(images[0], (int)x,(int)y,width,height,null);
  64.                 }
  65.                
  66.         }
  67.  
  68.         @Override
  69.         public void renderMulti(Graphics g) {
  70.                 if(hovering){
  71.                         System.out.println("hovering");
  72.                         g.drawImage(images[1], (int)x,(int)y,width,height,null);
  73.                 }
  74.                 else{
  75.                         g.drawImage(images[0], (int)x,(int)y,width,height,null);
  76.                 }
  77.                
  78.         }
  79.  
  80.        
  81.        
  82. }
  83.