How to dynamically replace images based on current screen resolution

Hi.

I’d like to know how to dynamically change images used in game. Is it possible in cocos creator? How do I get a resize event?

My idea is to have a group of images with dimensions (w, h) for resolution an default resolution and replace them for another group of images to other possible resolutions.

For instance,

image = 20x20 for resolution 480x320
image = 40x40 for resolution 960x640
image = 80x80 for resolution 1920x1280

Thanks.

node have “size-changed” event:this enum is cc.Node.EventType.SIZE_CHANGED.

1 Like

@zzf_Cocos It should solve the changing of image when screen is resized. Thanks.

And ny any chance would you know how to detect and change current resolution prior to the game starts?

Current resolution can use :

cc.view.getVisibleSize()

Change resolution can use :

cc.view.setDesignResolutionSize();
2 Likes

Thank you a lot.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.