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

2011/9/18

Paint Order - Order of detection bug

bourne bourne

2011/9/18

#
Hello, Recently I've had a bizarre experience that seems to occur by random chance. I have something like this in the World's constructor: setPaintOrder(Menu.class, ObjectBox.class, Background.class); Now this has proved to paint the Actors in the correct order. However, in the Menu class I have a conditional checking if the mouse was pressed on itself (the Menu). On some random times it will not believe it was clicked on after I had done so. I pause the scenario and right click where I'm trying to click on, (the region is covered by the Menu class object) and it comes up with methods from the ObjectBox or Background class objects that are behind the Menu class object. I try to drag from the point away from there, but nothing moves. I can right click and remove which shows to remove the objects behind the Menu. But after I remove both the ObjectBox and Background class objects, it still doesn't detect the Menu class object and picks up the World. I have no idea what it's doing Thanks, bourne
bourne bourne

2011/9/18

#
I may have a hunch on what it may be.. When the Menu Object is first added, its size is a fraction of the size of the screen, then it quickly expands to fit the screen by a line of code like: getImage().scale(...) Also I must add to my previous post that certain regions did seem to detect the Menu, but it seemed to be boxed region around the center where it did and on the outer sides that it didn't. (so to support my hunch). I seem to be able to reproduce the problem when the Menu is expanding, to click on it. Then it seems that the size that moment which I clicked on it is what is used for when concerning the order of detection. However, it seems it sometimes occurs without me clicking at all while it is expanding And I don't know if it has anything to concern with getImage().scale(...) because after it had expanded to fit the screen, it updates its image with setImage(...) in the act method
AwesomeNameGuy AwesomeNameGuy

2011/9/18

#
I dunno what your problem is, but be careful with mouse detection I have had some tricky issues in the past for example MousePressed and MouseDragged are different things, and if I remember correct MousePressed goes false when you drag the mouse even if you havnen't released the button yet. I don't know why it doesn't detect the menu when you pause it though.
bourne bourne

2011/9/18

#
Yeah I'm pretty sure it's not about how I used MousePressed(this) which is all I was using. And yeah I remember those being quite tricky but I'm confident I have it down now
bourne bourne

2011/9/18

#
Ha I suppose a quick fix for my program would change MousePressed(this) to MousePressed(null).. =D However, there's still something going on there..
danpost danpost

2011/9/20

#
@bourne, are you inside a loop and checking for a mouseclick or mousepress? Because if you are, after the first check within the loop, the mouseinfo will not update until the next cycle through act()s.
bourne bourne

2011/9/20

#
No, it's not nested in any such way
davmac davmac

2011/9/20

#
Having looked into it, changing the size of the image doesn't give any notification to the collision checking system that the actor(s) have changed size and that's why you see this. I guess it's case of bad API design; probably scaling an image should return a new image rather than modifying the original. I think you could work around it by copying the image to a new image, scaling that, and then setting it as the image for the actor.
bourne bourne

2011/9/20

#
Okay thanks davmac =)
You need to login to post a reply.