custom scale method

custom scale method
0.0 0


hey guys, lately i’ve been getting more annoyed with the black bars that come up when my game scales on different resolutions so i was thinking about scaling all my sprites in the game with >setScale; and positioning them with relative coordinates like>setPosition(ccp(size.width/2,size.height/2)); etc… will this be a good approach, or are there better alternatives?


getting the black bars might be better than a scale sometimes.

I’m a newbie in Cocos2DX but what I did in some tests is to make my layout in a fixed screen resolution, let’s say 480x800, and then scale all the graphics but also the positions, so I always have the same absolute position in all the screen ressolutions.

But I’m still investigating about this… it would be great to have a wide tutorial about screen resolutions handling and elements positioning.




well i made a different approach. What i did was arrange all the stuff relatively to screen size. for example if i needed a button on the bottom right of the screen i would scale it according to the screen resolution and then i would place it like (screenX-imageSizeX/2,imageSizeY/2) - imageSize are divided because my anchor points were in the middle of sprites, you could place an anchor point on the bottom right of the sprite and the coordinates would be (screenX,0)

sprite scaling worked great since i made my sprites on a medium resolution so scaling them up didn’t make them look horrible and they placed great. However one of the downsides of this is ads. If you place something near the top like a health bar or something you need to keep it lower then an ad would show up since you don’t want to hide a health bar from your player BUT if the game is run on a smaller res screen the ad banner will still obstruct the view and if you run on a higher resolution it will be significantly lower then you want.This is all because ads are on the android side of things so you can’t easily place then from the games c++ code but from my experience ads aren’t really worth it if you don’t have multiple thousands of gameplays a day