hyperandroid / CAAT

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

CATT.loop > callback not works #47

Closed jsasker closed 12 years ago

jsasker commented 12 years ago

Hi hyperandroid

CAAT.loop(30,function(){ console.log("onRenderStart"); });

it should output the string

but no output :| ,why ?

Im using "hyperandroid-CAAT-1a77f74"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// another question :

How can I call a function when mouseMove mouseDown ... on the "stage" ? P.S. even though the "stage" is empty .

like so :

stage.mouseMove=function(evt){ myShapeActor.setLocation(evt.point.x,evt.point.y); } Thanks

jsasker commented 12 years ago

Hi hyperandroid

after I change it to this.director... it calls the function , but seems the fps is very fast , even I change fps to 1

this.director.loop(1,function(){ console.log("onRenderStart"); });

Any idea ?

I want to call a function just like ActionScript > onEnterFrame

Thanks

robboerman commented 12 years ago

CAAT.loop does not consume a second argument. You can only provide a FPS argument which, in case you choose not to use the default requestAnimFrame method, set the number of frames per second the scene is rendered at (see the documentation). Because of the requestAnimFrame, the framerate is maximized to what the browser can handle.

From documentation:

CAAT.loop(fps) Main animation loop entry point.

Met vriendelijke groet,

Rob Boerman rob@robboerman.com twitter: @robboerman

http://appointsolutions.com

Op maandag 27 februari 2012 (w9), om 19:29 heeft jsasker het volgende geschreven:

CAAT.loop(30,function(){ console.log("onRenderEnd"); });

it should output the string

but no output :| ,why ?

Im using "hyperandroid-CAAT-1a77f74"

Help please


Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/47

hyperandroid commented 12 years ago

If you're looking for scene pre/post render hooks, you must redefine the scene object functions: onRenderStart( time ) and onRenderEnd( time ). Both functions receive current scene time as parameter . In previous CAAT versions, you had to call director.loop( fps, preRender, postRender ) method which was deprecated in favor or CAAT.loop method. Caat.loop only accepts one parameter, the expected animation FPS. If the browser accepts requestAnimationFrame (or variation) function, the FPS parameter is irrelevant, since these methods don't honor it. The fps parameter is just for browsers which don't have RAF method.

Let me know it it works for you.Regards,

-ibon

El 27 de febrero de 2012 19:29, jsasker < reply@reply.github.com

escribi:

CAAT.loop(30,function(){ console.log("onRenderEnd"); });

it should output the string

but no output :| ,why ?

Im using "hyperandroid-CAAT-1a77f74"

Help please


Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/47

jsasker commented 12 years ago

Hi robboerman and hyperandroid Thanks for your replies

So , that means no need to set the fps , the fps will be maximized automatically (as big as possible) , am I right ?

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I have an another question :

How can I call a function when mouseMove mouseDown ... on the "stage" ? P.S. even though the "stage" is empty .

like so :

stage.mouseMove=function(evt){ myShapeActor.setLocation(evt.point.x,evt.point.y); } Thanks

robboerman commented 12 years ago

Hi,

The scene itself is a descendent of an Actor too, so you should just create a custom mouseMove method on you scene and you should be set.

Met vriendelijke groet,

Rob Boerman rob@robboerman.com twitter: @robboerman

http://appointsolutions.com

Op maandag 27 februari 2012 (w9), om 21:02 heeft jsasker het volgende geschreven:

Hi robboerman and hyperandroid Thanks for your replies

So , that means no need to set the fps , the fps will be maximized automatically (as big as possible) , am I right ?

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I have an another question :

How can I call a function when mouseMove mouseDown ... on the "stage" ? P.S. even though the "stage" is empty .

like so :

stage.mouseMove=function(evt){ myShapeActor.setLocation(evt.point.x,evt.point.y); } Thanks


Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/47#issuecomment-4201714

hyperandroid commented 12 years ago

That's the correct way to do it. Thanks Rob for the answer.

I think this are not real CAAT issues but general purpose questions. Please post your CAAT questions directly to http://groups.google.com/group/caatjs/topics?hl=es which the general purpose CAAT forum.