New issue
 Projects > js > Issues > Bug #3500

Strange behavior of CCClippingNode on canvas render mode

Bug #3500 [New]
pandamicro 2013-12-25 02:51 . Updated almost 3 years ago

A old version HoleDemo of ClippingNodeTest can trigger this bug:

With the ScrollViewDemo and SpriteTest before and after the HoleDemo test, if we switch the test scene from ScrollViewDemo to HoleDemo, the ScrollViewDemo’s rectangle stencil will still act as a stencil to the HoleDemo’s element.
In the other way, if we switch from SpriteTest to HoleDemo, the SpriteTest’s triangle stencil will act as a stencil to the HoleDemo’s element.
So the HoleDemo’s sprite is always rotating in a mask.

The current version of HoleDemo has been modified to avoid this problem, so this is the original setup function that can trigger the bug:
`setup:function () {
var target = cc.Sprite.create(s_pathBlock);
target.setAnchorPoint(0,0);
target.setScale(3);

    this._outerClipper = cc.ClippingNode.create();
    this._outerClipper.retain();
    var transform = cc.AffineTransformMakeIdentity();
    transform = cc.AffineTransformScale(transform, target.getScale(), target.getScale());

    this._outerClipper.setContentSize(cc.SizeApplyAffineTransform(target.getContentSize(), transform));
    this._outerClipper.setAnchorPoint(0.5, 0.5);
    this._outerClipper.setPosition(cc.pMult(cc.pFromSize(this.getContentSize()), 0.5));
    this._outerClipper.runAction(cc.RepeatForever.create(cc.RotateBy.create(1, 45)));

    this._outerClipper.setStencil(target);

    var holesClipper = cc.ClippingNode.create();
    holesClipper.setInverted(true);
    holesClipper.setAlphaThreshold(0.05);

    holesClipper.addChild(target);

    this._holes = cc.Node.create();
    this._holes.retain();

    holesClipper.addChild(this._holes);

    this._holesStencil = cc.Node.create();
    this._holesStencil.retain();

    holesClipper.setStencil(this._holesStencil);

    this._outerClipper.addChild(holesClipper);

    this.addChild(this._outerClipper);

    this.setTouchEnabled(true);
}

`

pandamicro 2013-12-25 02:53

@
setup:function () {
var target = cc.Sprite.create(s_pathBlock);
target.setAnchorPoint(0,0);
target.setScale(3);
this.*outerClipper = cc.ClippingNode.create;
this.*outerClipper.retain();
var transform = cc.AffineTransformMakeIdentity();
transform = cc.AffineTransformScale(transform, target.getScale(), target.getScale());
this.*outerClipper.setContentSize, transform));
this.*outerClipper.setAnchorPoint(0.5, 0.5);
this.*outerClipper.setPosition), 0.5));
this.*outerClipper.runAction(cc.RepeatForever.create(cc.RotateBy.create(1, 45)));
this.*outerClipper.setStencil;
var holesClipper = cc.ClippingNode.create;
holesClipper.setInverted;
holesClipper.setAlphaThreshold;
holesClipper.addChild;
this.*holes = cc.Node.create();
this.*holes.retain;
holesClipper.addChild;
this.*holesStencil = cc.Node.create();
this.*holesStencil.retain;
holesClipper.setStencil;
this.*outerClipper.addChild(holesClipper);
this.addChild(this._outerClipper);
this.setTouchEnabled(true);
}
@

pandamicro 2013-12-25 09:23
  • Target version set to Unplanned

Atom PDF

Status:New
Start date:2013-12-25
Priority:Normal
Due date:
Assignee:-
% Done:

0%

Category:-
Target version:Unplanned

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.