PiRSquared17 / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

adding PHandle #233

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
After Adding PHandle to a pNode as a child and after applying PDragEventHandler 
the anchor point is moving too fast.It should not move that fast.What should i 
do to slow down it?   

What version of the product are you using? On what operating system?
windows xp

Please provide any additional information below.

PPath circle = PPath.createEllipse((float) (pointOne.getX() + pointTwo.getX()) 
/ 2,
                (float) (pointOne.getY() + pointTwo.getY()) / 2, 7, 7);

final PLocator circleLocator = new PLocator() {
            public double locateX() {
                return circle.getFullBoundsReference().getCenter2D().getX();
            }

            public double locateY() {
                return circle.getFullBoundsReference().getCenter2D().getX();
            }
        };

         PHandle pHandle = new PHandle(circleLocator);

        circle.addChild(pHandle);
        pHandle.addInputEventListener(new PDragEventHandler());

Original issue reported on code.google.com by vijay.ro...@uniken.com on 13 Dec 2011 at 12:51

GoogleCodeExporter commented 9 years ago
Vijay,

Your locator has a few defects:

1) You are returning the "X" coordinate in the locateY() method.
2) You should be returning *local* coordinates, not "full bounds" coordinates.

Your locator should look like:

        final PLocator locator = new PLocator() {
            public double locateX() {
                double x = circle.getBounds().getCenter2D().getX();

                return x;
            }
            public double locateY() {
                double y = circle.getBounds().getCenter2D().getY();
                return y;
            }
        };

Original comment by atdi...@gmail.com on 18 Dec 2011 at 8:31