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

2017/12/27

Incompatible Types

Cirion Cirion

2017/12/27

#
I'm trying to create a horizontal mirror of an image, but I receive the error "incompatible types: void cannot be converted to greenfoot.Greenfootimage". Below is the code I think is relevant:
private GreenfootImage run1 = new GreenfootImage("penguin1r.png");
    private GreenfootImage run2 = new GreenfootImage("penguin2r.png");
    private GreenfootImage run3 = new GreenfootImage("penguin3r.png");
    
    private GreenfootImage run4 = run1.mirrorHorizontally();
    private GreenfootImage run5 = new GreenfootImage("penguin2l.png");
    private GreenfootImage run6 = new GreenfootImage("penguin3l.png");
What should I do?
danpost danpost

2017/12/27

#
The method call on the right side of line 5 does not return any value (it is a 'void' method). So, you are not assigning anything to the 'run4' variable on the left. Set the variable to a copy of 'run1' using 'new GreenfootImage(run1)', then mirror the new image on the next line.
You need to login to post a reply.