Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

CATT.loop > callback not works #47

Closed
jsasker opened this issue Feb 27, 2012 · 6 comments
Closed

CATT.loop > callback not works #47

jsasker opened this issue Feb 27, 2012 · 6 comments

Comments

@jsasker
Copy link

jsasker commented Feb 27, 2012

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
Copy link
Author

jsasker commented Feb 27, 2012

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
Copy link
Collaborator

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:
#47

@hyperandroid
Copy link
Owner

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:
#47

@jsasker
Copy link
Author

jsasker commented Feb 27, 2012

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
Copy link
Collaborator

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:
#47 (comment)

@hyperandroid
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants