marialo wrote...
This time I get an error when I write setImage(image) since "image has private access in greenfoot.Actor". I made the instance variable GreenfootImage image public for the platform but it did not help

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | private void checkForBubble(Color bubbleColor, Color platformColor) { Bubble bubble = (Bubble)getOneIntersectingObject(Bubble. class ); if (bubble != null ) { Color color = bubble.getColor(); if (bubbleColor != color) { bubbleColor = color; for ( Object obj: getWorld().getObjects(Platform. class )) { if (platformColor == color) { setImage(image).setTransparency( 255 );} else if (platformColor = Color.RED) { setImage(image).setTransparency( 50 ); } } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 | { public GreenfootImage image; //... public Platform (String name, Color name) { image = new GreenfootImage (name + ".png" ); setImage(image); mName = name; mColor = color; } } |
1 | private void checkForBubble() |
1 | private Color bubbleColor; |
1 2 | Platform platform = (Platform)obj; Color platformColor = platform.getColor(); |
1 2 3 | GreenfootImage platformImage = platform.getImage(); // followed later with, for example platformImage.setTransparency( 200 ); |