When will we use pushScene and replaceScene?

I cocos2d, I use pushScene and replaceScene to go to the next scene. But, am I confused, what should we use?

When I use replaceScene in some places, the application crashes and gives errors like

-[UITextView length]: unrecognized selector sent to instance 0x842a750  
 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITextView length]: unrecognized selector sent to instance 0x842a750'  

But in my program, I do not pass the length of the UITextView. My program is this way
In scene1, I have a UITextView, and I replace this scene with scene2. Then

-(id)buttonPressed:(id)sender
{
    [description removeFromSuperview];  // It is the textView(description)
    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [scene2 node];

    [Scene addChild:Layer];

    [[CCDirector sharedDirector] setAnimationInterval:1.0/60];
    [[CCDirector sharedDirector] replaceScene: Scene];
}  

But, when I use pushScene in the presence of replaceScene, it works well. Please specify which one should be used in which cases?

thank

+3
source share
1 answer

replaceScene . pushScene , , , . - , Scene, . cocos2d.

UITextView 1, , . , .

+3

Source: https://habr.com/ru/post/1746552/


All Articles