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

2022/11/9

setPaintOrder() not doing anything

TheGrrMan TheGrrMan

2022/11/9

#
I have two objects, but one keeps blocking the other. So I tried using setPaintOrder(), and nothing happened. This code is in the world's act method. I've tried looking this up and can't find anything, and I've tried swapping orders, nothing happens. This is a (very abbreviated) snip of my code.
Edge Sidebar = new Edge();
public MyWorld()
    { 
super(800, 400, 1); 
setBackground("Map.png");
Sidebar.setImage("Sidebar.png");
addObject(Sidebar,700,200);
}
public void act()
    {   setPaintOrder(GUI_Image.class, Edge.class);}
^^this isn't even close to the amount of code I have written, but these are the only things I think could be related to my issue.
danpost danpost

2022/11/9

#
TheGrrMan wrote...
I tried using setPaintOrder(), and nothing happened.
Even after starting the scenario (clicking the 'Run" button)?
This code is in the world's act method.
The paint order will not be set until an act frame has been executed (by executing one act step or by starting the scenario) because you coded the setPaintOrder command in the act method. Move it up into the constructor -- before placing any actors into the world.
TheGrrMan TheGrrMan

2022/11/9

#
Well, it turns out that the problem was due to a goofed up if statement (forgot an '=') but this will be useful for future reference!
You need to login to post a reply.