Get Window Frame Resize Callback in Mac build

Hi,
Has anyone tried adjusting the game’s size according to resize window of game in mac.
i am not sure if creator provides resize callback. If it does ,kindly let me know.
Also, while changing the size , initially widget also does not seem to be effective in readjusting the game.
if anyone has pointers regarding this, it would be appreciated.

you could always try listening to the browsers resize event https://developer.mozilla.org/en-US/docs/Web/Events/resize

I am sorry but do you realise this question is specifically for Mac build.
I don’t think what you suggested would work in native environment, or would it ?

It’s the app is still being run in a webkit view so all browser events and more are still available.

Well that’s a good news. Thanks a ton brother.

@phero_constructs
I tried doing this , but none of the way seems to work.

window.addEventListener is not a function.

Let me know if you know what should be done to make it work

How about

‘’’
window.onresize = function() {
// Do something.
}
‘’’

tried it.
doesnt’ trigger. :confused:

@slackmoehrle Would appreciate any information regarding this :slight_smile:

@jare May be able to help

You can listen to the resize event in this way:

this._thisOnResized = cc.EventListener.create({
    event: cc.EventListener.CUSTOM,
    eventName: "window-resize",
    callback: function () { ... }
});
cc.view.on('canvas-resize', this._thisOnResized);

In 1.10, the widget will be able to readjusting when the window is resized by setting its alignMode.

1 Like