Bug with setResizeCallback() cc3.6.2?

Hi,
I’m currently use cc3.6.2, I try detect resizing on view(screen) with:
view.setResizeCallback(()=>{console.log("Rotate")});
Then I preview on browser, try Rotate button but it log “Rotate” second times.
image

Can anyone explain why?

Many thanks,

cc.view._resizeCallback=function(){
    console.log(Rotate)
}

try this?

Property ‘_resizeCallback’ does not exist on type ‘View’. Did you mean ‘setResizeCallback’?ts(2551)

cc.d.ts(20117, 9): ‘setResizeCallback’ is declared here.

I am using cc 3.6. maybe this property was remove @Koei

@Koei do u know how do detect screen rotate on android phone with cocos ? I try resizecallback but it does not works

Sorry, I misunderstood.

This is because when the canvas is rotated, ‘window-resize’ and ‘orientation-change’ are triggered, and both event callbacks are resizecallbacks.

How did you rotate the canvas?

1 Like

@Koei I have understood my problem, about my second question, What callback function that i can use when android phone change orientation?

   jsb.onResize = (event) => {
       console.log('resize');
   };

try this.

@Koei what is jsb? I try search property onresize at cc apis but just found them:

Just make my question simple: How to detect orientation change at native platform without setresizecallback

Use this one.

@deprecated — since v3.6.0, please import native from ‘cc’ module instead like import { native } from 'cc'; .

do u know how to import @Koei