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

2018/6/14

how to detect a background image

McMaxi2002 McMaxi2002

2018/6/14

#
I have different background images which change so that in an actor a bar should move at different speeds but I have no idea or approach how to do it
danpost danpost

2018/6/14

#
Do you mean the background is chosen from among the different images for different types of worlds? and the actor stays in the one type world throughout (like) a level?
McMaxi2002 McMaxi2002

2018/6/14

#
if(getWorld().getBackground(GreenfootImage("insert name of picture here"))==true){
             move(-1);
                     
        }
I'm not really sure what you meant because my English is not that good but I think it's just as you said. Here's an example of what I meant
danpost danpost

2018/6/14

#
McMaxi2002 wrote...
<< Code Omitted >> Here's an example of what I meant
You will probably need to maintain the image itself or an int value that represents which image was chosen in a field so that it (the field) can be checked to determine which was used. The only way you would be able to tell using getBackground is if you checked the color of one or more pixels of the image to narrow down which was chosen (which you really would not want to do).
You need to login to post a reply.