Cc.label in child code

Hi,

Please see below code:

   GamePauseOnOffPress:function(){
   this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
     // Pause Button Press 1 Pause Game
     var pausetext=this.getComponentInChildren(cc.Label);
     this.countpause++;
    **pausetext.string = "PAUSE";**
    cc.audioEngine.playEffect(this.buttonsoundpause);
    cc.game.pause();
    // Pause Button Press 2 Unpause Game
   if(this.countpause>=2){
    cc.game.resume();
   **pausetext.string = "";**
   this.countpause = 0;
   }},this);},

When I press the button onced it’s supposed to display via cc.label PAUSE, and when I press another time, blank the string…This works via simulator, and when I export to apk or ipa, however, it doesn’t show string PAUSE on Web export…? Any ideas…God Bless…

Sincerely,

Sunday

could you make a minimal bare bone demo to reproduce this issue?

I could take a look at this issue.

One more question, do you mean this code only doesn’t work on Web export?

I mean in the web preview mode, the effect is OK too?

Hi @owen

Thanks for the help, yes, it doesn’t work on Web Export, I can see that it works on simulator, it shows the PAUSE string label, but during the browser testing, it doesn’t show, I’m going to export another DESKTOP , and upload to server, and see. In fact in Module Config, I have checked Label. God Bless…

Sincerely,

Sunday

Hi @owen,

If not mistaken, I think, this could be a bug ? I just test it out with a regular button, and applied a child node label(cc.label), and used the code above, and still it displays in simulator, but not on web. Just like in export, I export to apk, and ipa, and it works as it’s supposed to. But when I export to Web Desktop, it doesn’t display the PAUSE string. The code seems to be working, by pausing the game, and then press, unpause game, but it just doesn’t display the string = PAUSE like below:

Maybe, it’s my code, but it seems very strange though…God Bless…

Sincerely,

Sunday

could you provide a test demo? I need to reproduce this issue at my side.

Hi @owen,

I’ve attached a **testpausebutton.zip (41.6 KB)
** please let me know…God Bless…

The project is not a valid Creator project, could you please send me a complete one?

Hi @owen

Here’s the complete file structure…I’m on a Mac (OSSierra )…test.zip (559.0 KB)

Please let me know…God Bless…

Sincerely,

Sunday

It seems related to the function call cc.game.pause().

If I remove the function call together with cc.game.resume(), everything works fine as expected.

I think there must be some implementation difference of cc.game.pause on Native platform and Web platform.

Is there any special reasons you should add cc.game.pause here?

thanks.

Hi @owen

So then, what would be the correct implementation code wise, so it would work both in native and web? The reason is that if i touch the button, it would pause the game, then if i touch again, it would resume the game…God Bless…

Sincerely,

Sunday