cocos2d sprite state after beeing applied a CCFadeOutBLTiles effect - cocos2d-iphone

What is happening to a sprite (or layer) after you apply something like a CCFadeOutBLTiles effect , it seems to be disapeared, how to get it visible to start using it again ?

Set the opacity property to 255. Also make sure visible is set to YES.

Related

correct way of updating a QGraphicsView from QGraphicsScene

I have implemented a QGraphicsScene to contain instances of QGraphicsItem of a few different classes implemented by me. What I still don't understand is how the QGraphicsView associated with this scene is updated.
When I call addItem(QGraphicsItem) the scene seems to redraw displaying the newly added items.
When I change properties of my QGraphicsItem instances (e.g. calling setVisible(bool)) it seems that the view is not updated automatically.
I currently call QGraphicsScene::update() without any arguments to draw the new state. this works in most cases, however in some of them it fails ( QGraphicsItem's paint() method is not called. I set a breakpoint there but whether it is reached or not depends on the zoom level in the QGraphicsView. I have to zoom out to a certain level for it to get called again).
It doesn't work when I pass the bounding box of the changed item (scene coordinates) to QGraphicsScene::update(QRect). I can't see objects changing.
Can anybody give me a hint what is the correct way of implementing this? How do I notify the view correctly of changes in certain areas, what does the behaviour depend on. I think there's something wrong with my assumptions about coordinate systems. Thanks a lot for your explanations.

Get MPxLocator to draw when attribute changes

I have a Maya/cpp code with an MPxLocator. This locator has an attribute called "Frame", and whenever the frame changes, I have a function that updates that attribute:
MFnDagNode myDagNode(MPxLocatorMObject);
myDagNode.findPlug("Frame").setValue(frame);
However the draw functions is not always started, only sometimes. How can I make the MPxLocator "dirty" when frame attribute is changed ?
Found out that the MPxLocator gets refreshed only if it is visible on screen (or at least the point representing its coordinates).

Cocos2d CCLabelBMFont how to add a background to string

I am wondering how can I add a border & background to labels generated via CCLabelBMFont class in cocos2d.
I don't want to use sprites because my labels are generated on the fly and will keep changing and the size of labels are also different.
Also, I want user to touch and move these labels across the screen. When user picks a label it wiggles a bit like in free air. In that case, I wish to keep low complexity and preserve memory and cpu calculations.
Anyone knows best ways to achieve this?
IOS app LetterPress has similar effects.
Create your own class, that will incapsulate creation of complex node.
It will have several layers, for example, the first layer can be simple CCLayerColor of given rect with zOrder -2, the next layer will be your CCLabelBMFont with zOrder -1 and then you can overload draw method to draw border over your control. All that you draw in this method will be drawn with zOrder 0.
Then you can encapsulate any effects in this class. For example, you can rotate it a bit with method pick, etc. Whatever you want.

Cocos2d sprite is drawn outside screen when transition

When I do page transition that shows the outside part of the stage (like CCTransitionFlipX), I can briefly see the sprites outside the screen while transition. It is really annoying. I thought I can manually check the position of the sprite in realtime and remove if it is off the screen. But that won't work if that sprite is partially outside. Is there something like UIKit's clipSubviews in cocos2d?
There's a ClippingNode class that might help.
Since the flip animation allows the user to see more than just the visible screen area, because the screen rotates, I think the behavior you observed may be expected.

Does the .visible property affect performance?

I can turn the .visible value for CCNodes, but I wonder, can an insivisible node consume less memory/processing than a visible one? Can I set the .visible property to NO when my objects are outside the screen to optimize? Or does cocos2d already do that stuff for me?
Invisible nodes are typically skipped when it comes to being rendered. On the other hand, nodes with visible set to YES will invoke OpenGL draw calls, regardless of whether they are on or off the screen (See Riq's comment here). ie. cocos2d does not seem to perform any kind of culling for offscreen elements.
If this is indeed the case, I would simply just set visible = NO (no harm and definitely not hard!) if they are completely off the screen to avoid invoking any additional draw calls. Also note that these offscreen node objects are still physically present and still take up the same memory, even if they have visible set to NO. Furthermore, if these nodes are already running some animations/actions, they will continue updating outside the screen, unless you unschedule them.
Check this posts from the official cocos2d forum
is rendering invisible sprites in spritebatchnode cheap?
Performance Difference between visible = no and removeChild
Bad perfomance - many sprites with the same texture
Also, you can test it by yourself but i think that those post will help.
IMO setting visible=NO is enough, but depends on the sprite count.