StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
282 stars 89 forks source link

Other sprites vanish when you start drawing #117

Open MrJop opened 10 years ago

MrJop commented 10 years ago

So I have this setup inside a Starling Sprite (below are all Starling elements):

a Quad an Image an Image a Shape 5 Buttons

Up to so far everything is ok and everything is visible. But as soon as I start drawing in the Shape, my Buttons and Images all disappear. It looks like they're not completely gone as the buttons still work, I just can't see them.

When I then clear the graphics in the shape, everything returns to normal. It's not a case of the visual inside the Shape blocking things as the Buttons in the higher layers also disappear and I can still see the Quad which is a solid background colour.

Any ideas?

IonSwitz commented 10 years ago

Nope. Without code to reproduce this, it is very hard to have any idea what could be wrong. The times I have seen similar bugs, the Shape has been incomplete, for example, a fill was used without closing the shape with proper lineTo calls, or similar issues.

Could you please supply the calls you do to the Shape? I will see if I can find another issue where this occured as a reference

MrJop commented 10 years ago

Thanks for the quick reply. This is the draw call I'm making:

var g:Graphics = myCanvas.graphics;
g.clear();
g.beginFill(0xff00ff);
g.moveTo(pos.x * pe.physScale, pos.y * pe.physScale);
g.lineTo(pos.x * pe.physScale, pos.y * pe.physScale);
g.lineTo(pos.x * pe.physScale, pos.y * pe.physScale);
g.lineTo(pos.x * pe.physScale, pos.y * pe.physScale);
g.endFill();
IonSwitz commented 10 years ago

Sorry, but.. that results in a point that might degenerate the math code, and it might even throw an exception. The same vertex points in all vertices?

What are you trying to achieve?

MrJop commented 10 years ago

sorry my bad. I took out bits of code before copy pasting it. The drawing works fine. Its just the other elements that are disappearing is the issue. This also happened when I just had a simple drawing application where you move your finger and a line gets drawn. I've copy pasted that code below:

var touch:Touch = e.getTouch(stage); var position:Point = touch.getLocation(stage);

        switch(touch.phase){
            case TouchPhase.BEGAN:
                //myCanvas.graphics.beginFill(Math.floor(Math.random()*16700000));
                myCanvas.graphics.lineStyle(20, Math.floor(Math.random()*16700000));
                myCanvas.graphics.moveTo(position.x, position.y);
                break;

            case TouchPhase.MOVED:
                myCanvas.graphics.lineTo(position.x, position.y);
                break;

            case TouchPhase.ENDED:
                myCanvas.graphics.endFill();
                break;
        }