hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

Problem with sprite fonts #91

Closed alexac1970 closed 11 years ago

alexac1970 commented 11 years ago

Hi, i've modified demo5 to draw the sprited text on a concrete position with "setLocation" instead of using a path to move the text and i get this error:

"Uncaught TypeError: Object # has no method 'drawText'" on line 8927 in caat.js v0.4.421

hyperandroid commented 11 years ago

Could you post the complete sample please ? Thanks.

alexac1970 commented 11 years ago

Sure, in your demo5 example just replace the setPath statement of the text2 actor with a setLocation, setPosition, setBounds or centerAt:

        var text2 = new CAAT.TextActor().
            setFont( font ).
            setText( "0123456789" ).
            setTextAlign("left").
            setTextFillStyle(gradient2).
            setTextBaseline("top").
            setPath(
                p,
                new CAAT.Interpolator().createExponentialInOutInterpolator(3)).
            setPathTraverseDirection( CAAT.TextActor.TRAVERSE_PATH_BACKWARD );
        scene.addChild(text2);

I replaced setPath statement with: setLocation(200,200):

        var text2 = new CAAT.TextActor().
            setFont( font ).
            setText( "0123456789" ).
            setTextAlign("left").
            setTextFillStyle(gradient2).
            setTextBaseline("top").
            setLocation(200,200);
        scene.addChild(text2);
hyperandroid commented 11 years ago

Have changed CAAT.Foundation.SpriteImage drawString function to be exactly equal to CAAT.Module.Font.Font drawText function. That fixes it. The problem is that a SpriteImage is being built out of an Image, and it is being used as a font. Will be fixed in next release. Thanks.

  • ibon