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.
Can anyone explain why?
…
Many thanks,
Koei
December 19, 2022, 8:41am
#2
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
Koei
December 20, 2022, 3:08am
#5
Sorry, I misunderstood.
This is because when the canvas is rotated, ‘window-resize’ and ‘orientation-change’ are triggered, and both event callbacks are resizecallbacks.
thinhnguyen:
rotate on android
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?
Koei
December 20, 2022, 7:06am
#7
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
@deprecated — since v3.6.0, please import native
from ‘cc’ module instead like import { native } from 'cc';
.
do u know how to import @Koei