This site requires JavaScript, please enable it in your browser!
Greenfoot back
DSB
DSB wrote ...

2018/6/1

My project doesn't finish compiling

DSB DSB

2018/6/1

#
The project contains just one actor class and the default MyWorld class. When pressing the "compile" button, it keeps compiling this actor class and won't stop. This is the code I'm trying to compile:
import greenfoot.*;
import java.awt.image.BufferedImage;
public class Sprite extends Actor
{
    public void act() 
    {
       spriteTexturing(0,0); 
    }

    public void spriteTexturing(int spriteNR,int paletteNR)
    {
        byte sprite=(byte)spriteNR;
        byte palette=(byte)paletteNR;
        int X=0;
        int Y=0;
        int dX=16;
        int dY=16;
        BufferedImage spritesheet=readImage("spritesheet.png");
        BufferedImage spriteTexture=spritesheet.getSubimage(0,0,16,16);
    }
}
some of the stuff, like the conversion to byte variables or the four int valuse, can be ignored, as they are not in use yet. I believe the problem has something to do with the BufferedImage stuff. Does anyone know how to fix it?
danpost danpost

2018/6/1

#
Line 18 calls a method called readImage. I know it is not a member of the Actor class; nor is it shown in your Sprite class. As far as I can tell, it is an unknown method.
DSB DSB

2018/6/1

#
Thank you. Is there an easy, simple way to turn a png image into a java image?
danpost danpost

2018/6/1

#
DSB wrote...
Thank you. Is there an easy, simple way to turn a png image into a java image?
BufferedImage spritesheet = (new GreenfootImage("spritesheet.png")).getAwtImage();
The getAwtImage method has been available almost from the beginnings of Greenfoot.
You need to login to post a reply.