0
\$\begingroup\$

I want to create sprite with size is relative to the screen size. I.e: Sprite size is equal to screen width * 0.2.

I use setContentSize and setScale but it gives ugly and poor graphic quality. I've read about multiple resolution supports, but it doesn't work on this case because i need sprite size adapt to the any screen size.

Testing on iPhone 7, i scale an image from 512x512 to 64x64.

This is error of cocos2d-x or anyway to archive it?

\$\endgroup\$
0
\$\begingroup\$

On the iphone7 the width is 1334 pixels. If you go *.2 thats 20 percent of the screen = 266.8.

My suggestion: Start at the highest resolution you want your final game to support (1k, 2k?). Create the proper biggest size image you need for your top resolution and logical smaller versions for inbetween resolutions to support. Understand how appdelegate.cpp implements sizes. Load the sprite at the proper size. If there's an in game reason you want to scale your image down in engine then make sure you're generating mipmaps.

setContentSize doesn't do what you're trying to do, it affects the sprites texture rect. Use setScale by itself.

\$\endgroup\$
  • \$\begingroup\$ The trouble is scaling makes sprite aliasing, jagged. I can create multiple images for iPhones, but i couldn't do it for android devices, because there're too many of resolutions. You can read baskus's answer here: discuss.cocos2d-x.org/t/… \$\endgroup\$ – TomSawyer May 18 '17 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.