Following are two similar sets of code with the newObject~~>setTag placed at 2 different positions:
Code A:
@ newObject = CCSprite::create~~ IDCOCONUT]);
newObject~~>setPosition + 1) * 80 + 24, 60) );
Bar_Panel~~>addChild(newObject, 0, 10);
invItems~~>addObject;
newObject~~>setTag(objID~~>getTag);
CCLog, objID~~>getTag());@
Code B:
@ newObject = CCSprite::create(fName[objID~~>getTag~~ IDCOCONUT]);
newObject~~>setTag);
newObject~~>setPosition( ccp((invItems~~>count + 1) * 80 + 24, 60) );
Bar_Panel~~>addChild(newObject, 0, 10);
invItems~~>addObject;
CCLog, objID~~>getTag());@
objID, Bar_Panel is of type CCSprite
invItems is of type CCArray
Code A runs fine and the log shows:
tag in addTOInv function : 113 113
but Code B always shows 10 as the tag of newObject
tag in addTOInv function : 10 113
Should there be any restrictions on when the tag can be set (probably like only after the position has been set or anything like that) ?