israelCanul / rokon

Automatically exported from code.google.com/p/rokon
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Rotated window: Sprites disappearing #125

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use a scene with a background and sprites
2. Set a normal window (e.g. 0,0,800,600) - everything works fine.
3. Set an inverted window (e.g. 800,600,-800,-600)

What is the expected output?
A rotated screen (180 degree)

What do you see instead?
All sprites will disappear. But the background is rotated correctly and when I 
click on an expected sprite-position (sprite is touchable), the handler is also 
called correctly. So obviously there is a problem while drawing the sprites.

What version of Rokon are you using?
Trunk

Original issue reported on code.google.com by tobias.w...@gmail.com on 23 Jul 2010 at 3:13

GoogleCodeExporter commented 8 years ago
The problem is in DrawableObject.java, function isOnScreen().
This function uses currently a calculation that only works for positive values 
for x, y, width and height.

Original comment by tobias.w...@gmail.com on 23 Jul 2010 at 3:40

GoogleCodeExporter commented 8 years ago
This fixes the problem:

    public boolean isOnScreen() {
        if(parentLayer == null) {
            return false;
        }
        float maxSize = width;
        if(height > width) maxSize = height;
        if(parentLayer.ignoreWindow || parentScene.window == null) {
            if (getX() - (maxSize / 2) < RokonActivity.gameWidth && getX() + maxSize + (maxSize / 2) > 0 && getY() - (maxSize / 2) < RokonActivity.gameHeight && getY() + maxSize + (maxSize / 2) > 0) {
                return true;
            }
        } else {
            boolean validY=false;
            if(parentScene.window.height<0)
            {
                if(getY() - (maxSize / 2) < parentScene.window.getY() && getY() + maxSize + (maxSize / 2) > parentScene.window.height + parentScene.window.getY())
                    validY=true;
            }
            else
            {
                if(getY() - (maxSize / 2) < parentScene.window.height + parentScene.window.getY() && getY() + maxSize + (maxSize / 2) > parentScene.window.getY())
                    validY=true;

            }
            boolean validX=false;
            if(parentScene.window.width<0)
            {
                if(getX() - (maxSize / 2) < parentScene.window.getX() && getX() + maxSize + (maxSize / 2) > parentScene.window.width + parentScene.window.getX())
                    validX=true;
            }
            else
            {
                if(getX() - (maxSize / 2) < parentScene.window.getX() + parentScene.window.width && getX() + maxSize + (maxSize / 2) > parentScene.window.getX())
                    validX=true;
            }

            if (validX && validY) {
                return true;
            }
        }
        return false;
    }

Original comment by tobias.w...@gmail.com on 23 Jul 2010 at 3:59

GoogleCodeExporter commented 8 years ago
You're right, thanks

Original comment by rtaylor205@gmail.com on 25 Jul 2010 at 9:04