Forum > C# > Bugs

Bugs

By TheDevil Posted 2012-03-04 17:52 Comments 9
TheDevil
  • Posts: 110

Hi,
First of all, a big thank-you to everyone who helped port this.
Second, while using cocos2d-x for XNA, I have come across some issues (at lease I think they are) as follows:
1) On removing a child from CCSpriteBatchNode, it gets drawn on the screen again from the next draw call onwards. (Have not yet found any solution. Please help)
2)In CCMenu::menuWithItem(), the cocos2d-x internally appends a null to it before calling CCMenu::menuWithItems(). This cause the code to crash. Removing the null that is getting added in the function, fixes the bug.
3)If we make a particle effect with the help of Particle Designer( http://particledesigner.71squared.com/index.php ) , it cause the code to crash again. This is because the emitter type, is stored as a float in the plist file and it is parsed as an integer when the file is being read. Changing the parsing to a float parse fixes the issue.
4) When using the action CCFadeOut on a sprite, it cause the screen to go fade to a blue color temporarily as if we have done a fade to blue. Have not found a fix for this yet, as am not familiar with DirectX. Any help is appreciated.

Thanks.

theshivu
  • Posts: 21
  • Location: Banglore

#1 RE: 2012-03-05 07:15

are you removing the correct one by removechild like this?

public void spritemovefinished(SelectorProtocol sender)
{
CCSprite sen = (CCSprite)sender;
this.removeChild(sen, true);
}
or what ,i did faced the same problem..

TheDevil
  • Posts: 110

#2 RE: 2012-03-05 07:19

I am directly removing the sprite as it is stored in a class variable. It disappears for one cycle and then in the next cycle is visible near the bottom left of the screen.

Thanks

theshivu
  • Posts: 21
  • Location: Banglore

#3 RE: 2012-03-05 07:30

i didnt catch you , i am a beginner i straight away give my lines which faced ,
i hope it helps……… if you used actionmove or sequence,,

CCCallFunc actionMoveDone = CCCallFuncN.actionWithTarget(tSprite,spritemovefinished);
/////////////////////**************************here tsprite is the sprite am using you can use ur class object to pass and remove that in sprite movefinished method
tSprite.runAction(CCSequence.actions(actionmove,actionmove1,actionMoveDone));
//Here i called runaction with tsprite ucan call object.yoursprite.runaction or whatever……………

public void spritemovefinished(SelectorProtocol sender) {
CCSprite sen = (CCSprite)sender;
this.removeChild(sen, true);
}

huangrh
  • Posts: 171

#4 RE: 2012-03-05 09:50

hi, Nidhi Ajwani, about your questions:
1) On removing a child from CCSpriteBatchNode, it gets drawn on the screen again from the next draw call onwards. (Have not yet found any solution. Please help)

i don’t reproduce the problem, could you give the sample code here.
and i have create an issue to trace this problem, see http://www.cocos2d-x.org/issues/1011

2)In CCMenu::menuWithItem(), the cocos2d-x internally appends a null to it before calling CCMenu::menuWithItems(). This cause the code to crash. Removing the null that is getting added in the function, fixes the bug.

this is not a bug, the node doesn’t allow to add a null child.

3)If we make a particle effect with the help of Particle Designer( http://particledesigner.71squared.com/index.php ) , it cause the code to crash again. This is because the emitter type, is stored as a float in the plist file and it is parsed as an integer when the file is being read. Changing the parsing to a float parse fixes the issue.

this is a problem to a certain extent.
the emitter type should be integer, when the value is float(in fact, it is unreasonable), it crashes.
but now we will deal with integer and float together, issue 1012(http://www.cocos2d-x.org/issues/1012) is created for this.

4) When using the action CCFadeOut on a sprite, it cause the screen to go fade to a blue color temporarily as if we have done a fade to blue. Have not found a fix for this yet, as am not familiar with DirectX. Any help is appreciated.

i don’t catch you here, could you paste a screenshot here.
CCFadeOut acts well in actions tests now

TheDevil
  • Posts: 110

#5 RE: 2012-03-05 10:13

Hi,
1) My code is as follows:
@
if (batchNode.children.Contains(*cannonBall.sprite))
{
System.Diagnostics.Debug.WriteLine;
batchNode.removeChild;
}
*cannonBall.destroyBall();
_cannonBall = null;

2) in the cocos2d-x code, this is what happens:
@
public static CCMenu menuWithItem(CCMenuItem item)
{
return menuWithItems(item**,null**);
}
@

which cause the code to crash. If I change it to this
@
public static CCMenu menuWithItem(CCMenuItem item)
{
//TheDevil
return menuWithItems(item);
//
}
@

it works.

4) My code is
@

switch (number)
{
case 1://try again
one = CCSprite.spriteWithSpriteFrameName(“nopressure.png”);
break;
case 2://try harder
one = CCSprite.spriteWithSpriteFrameName(“youcandoit.png”);
break;
case 3://excellent
one = CCSprite.spriteWithSpriteFrameName(“excellent.png”);
break;
case 4://good shot
one = CCSprite.spriteWithSpriteFrameName(“goodshot.png”);
break;
default:
break;
}
one.position = new CCPoint(240, 200);
this.addChild(one);
one.runAction(CCSequence.actions(CCFadeOut.actionWithDuration(1.5f),
CCCallFunc.actionWithTarget(this, this.removeSelf)));

1.png (236.6 kB)

TheDevil
  • Posts: 110

#6 RE: 2012-03-05 10:15

More screenshots

2.png (236.1 kB)

3.png (174.9 kB)

4.png (182.9 kB)

huangrh
  • Posts: 171

#7 RE: 2012-03-07 08:07

yep, about menuWithItem(CCMenuItem item), this is a bug, i have corrected it

physix
  • Posts: 6
  • Location: Seattle

#8 RE: 2012-07-22 19:40

Regarding the first problem reported by Nidhi and tracked by issue #1011 (http://www.cocos2d-x.org/issues/1011), it is caused by code commented out in the framework.
For me it was happening only occasionally and I tracked down the repro steps to using z-order when adding a sprite.
To fix, it replace the removeQuadAtIndex function inside CCTextureAtlas.cs with the following:

public void removeQuadAtIndex(int index)
{
Debug.Assert(index < m_uTotalQuads, “removeQuadAtIndex: Invalid index”);
if (index == m_uTotalQuads - 1)
{
m_pQuads[index] = null;
}
else
{
for (int i = index; i < m_uTotalQuads - 1; i+*)
{
m_pQuads[i] = m_pQuads[i* 1];
}
m_pQuads[m_uTotalQuads - 1] = null;
}
m_uTotalQuads—;
#if CC_USES_VBO
m_bDirty = true;
#endif
}

It solved the problem for me. Hope it helps!

jwa@javatopia.com
  • Posts: 243
  • Location: Totally Evil Entertainment - San Diego

#9 RE: 2012-08-07 15:32

On #3.

CCParticleSystem.cs, line 983 in current repo:

m_nEmitterMode = ccUtils.ccParseInt(ChangeToZeroIfNull(valueForKey(“emitterType”, dictionary)), NumberStyles.AllowDecimalPoint);

This should work for you now. If you are still getting an error with your custom particle system, please let us know.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps