LayerColor flickering while MoveTo action is active

I’ve recently started using Cocos2d-x V3.0 in a new project. It’s heavily based in rectangles and colors (it’s an adaption of a book for children). Anyway, during my first tests, I’ve noticed a weird behavior in iOS (only the devices, not in the simulator for example).

I think the code is fairly simple so you can understand:

    Size visibleSize = Director::getInstance()->getVisibleSize();
    LayerColor *rect = LayerColor::create(Color4B(203,155,36,255), visibleSize.width, visibleSize.height);
    rect->setContentSize(visibleSize);
    rect->setPosition(origin.x, rect->getContentSize().height * 2);
    this->addChild(rect);
    
    MoveTo *mv = MoveTo::create(2, Point(origin.x, origin.y + 80));
    EaseOut *eo = EaseOut::create(mv, 2);
    rect->runAction(eo);

The director is configured to run animations at 1/60.

During this fairly simple movement, the rectangle LayerColor which has a brown-ish on the top of the scene, which has a white background shows some rendering issues. Even when the animation is over, it keeps printed on the screen. (Screenshot attached from an actual iPhone 5s). I could reproduce the behavior in Mac Mini retina too.

Any ideas? Am I missing something here or misusing the LayerColor?


photo1.png (26.5 KB)

I tried this in the iOS simulator and on my iPad Mini and it works. I see a brown layer draw. see attached.

@slackmoehrle did you move it? If I draw a layer, it will work, but it will “break” if I move it. I’m trying different approaches here, like using sprites or extending the Layer class and overriding the draw method - I’m not sure yet which way to follow.

Can you clarify “move it” ? You mean change:

 MoveTo *mv = MoveTo::create(2, Point(origin.x, origin.y + 80));

as the code above doesn’t respond to touch events.

@slackmoehrle no touch events, just the pure animation. Anyway, I will see what the issue can be, including testing on other iOS devices. It may be some GL/RGB configuration, I’m not sure yet.

I’ve tried using Sprite and even DrawNode with the same results. Anyone could point to a possible solution?

I’m using v3.0, and I created the project using the shell command as per Github instructions. Is anyone facing issues with iOS devices runnig 7.1.x and what appears to be rendering issues? RGB space?

Cheers!

Well, disabling the GL_DEPTH_TEST seemed to do the job, though I’m not sure about the effects of this for now.

I realize this is a bit of an old post, but I too am seeing this on device (iPad 4) but not on simulator, and am using Cocos v.3.2.

I have a image Sprite as the child of a LayerColor, and when I runAction MoveBy on the LayerColor, there is a flickering and the LayerColor shows through the Sprite.

At one point in my code I set

Director::getInstance()->setDepthTest( true ); 

because it helped with the page curl transition (in v.2.2.0, I have not retested in v3.2), and thus setting it to false once the transition completes resolves the issue. I noted that Sprite3D sets this to true.

I threw together some sample code to show the issue, you can put this at the end of HelloWorld init() and run on device:

LayerColor *layerColor = LayerColor::create( Color4B(255, 0, 0, 255));
layerColor->setContentSize( Size( 640, 480 ) );
layerColor->setPosition(Vec2(visibleSize.width/2 + origin.x, (visibleSize.height/2 + origin.y) - 1536 ));
layerColor->ignoreAnchorPointForPosition( false );
layerColor->setAnchorPoint( Vec2( 0.5, 0.5 ));
layerColor->setScale( 3.0 );
this->addChild(layerColor, 0);

Sprite *sprite = Sprite::create("HelloWorld.png");
sprite->setPosition( Vec2( 320 , 240 ) );
layerColor->addChild(sprite, 0);

Director::getInstance()->setDepthTest( true );  // set to true causes flicker

MoveBy *mba = MoveBy::create( 4.0, Vec2( 0, 1536 ));
Repeat *ra = Repeat::create( Sequence::createWithTwoActions( mba, mba->reverse() ), 10 );
runAction( TargetedAction::create( layerColor, ra ));