Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
ccbRegisterOnFrameEvent

areibma
Registered User
Quote
2018-02-25 08:45:20

How to call ccbRegisterOnFrameEvent(onFrameDrawing) inside onAnimate.


areibma
Registered User
Quote
2018-02-25 08:52:35

Got it drawn.
But suppose I am drawing a circle using ccbRegisterOnFrameEvent. Once I don't need it anymore, how do I remove that circle or how do I stop drawing it?
Calling ccbUnregisterOnFrameEvent is not removing that circle!


niko
Moderator
Quote
2018-02-25 15:05:49

What platform are you using?
If unregistering doesn't work (which it should, but as workaround:), you can store a variable and set it to 'true' and 'false' if you should draw a circle. It it is set to false, just don't draw it.
That would definately work, independent of the unregister function works or not.


areibma
Registered User
Quote
2018-02-25 15:38:18

here is the drawing code, calling from inside onMouseEvent

var down = false;
var mX = 0.0;
var mY = 0.0;

if (mouseEvent == 2)
{
down = false;
}

if (mouseEvent == 3)
{
down = true;
}

// draw the rectangle
function onFrameDrawing()
{
var mouseX = ccbGetMousePosX();
var mouseY = ccbGetMousePosY();

ccbDrawColoredRectangle(0x444BC050, mX, mY, mouseX, mouseY);
}

if (down == true)
{
// register the drawing function
ccbRegisterOnFrameEvent(onFrameDrawing);
}
else
{
// unregister the drawing function
ccbUnregisterOnFrameEvent(onFrameDrawing);
}


It is windows 7. Exporting as a exe.


niko
Moderator
Quote
2018-02-25 16:32:14

Ah, I think the problem is that your function is inside that function. You are always unregistering a different function. Move the function and the down to outside the onMouseEvent, then is should work.


areibma
Registered User
Quote
2018-02-25 17:34:55

Ok, got it, down was not needed, just called it directly. Thank you.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact