Cocos2DXNA / cocos2d-xna

XNA Port of Cocos2d-X
www.cocos2dxna.com
227 stars 123 forks source link

High res image loading uses the low res content scale factor #359

Open totallyeviljake opened 10 years ago

totallyeviljake commented 10 years ago

From codeplex:

https://cocos2dxna.codeplex.com/discussions/461066

The system loads a high res image properly, but it uses the low res content scale factor which then makes the high res image too large (upscaled).

doubleday commented 10 years ago

When using the scale hack mentioned in the discussion I run in the problem that ConvertToNodeSpace does not work anymore for in bounds calculations. When I'm doing

var converted = ConvertToNodeSpace(touch.Location);

The converted x, y will be doubled. I guess this is collateral damage and will not be an issue when this is fixed properly?

doubleday commented 10 years ago

Me again. Just found out by checking cocos2d-x that I need to set the content scale factor on the director.

So for ios this works fine for me:

var height = CCDrawManager.FrameSize.Height;
if (height > 480)
    height /= 2;

CCDrawManager.SetDesignResolutionSize(320, height, CCResolutionPolicy.ShowAll);
CCDirector.SharedDirector.ContentScaleFactor = CCDrawManager.FrameSize.Width / CCDrawManager.DesignResolutionSize.Width;

So my problem is solved and this might not be a bug after all...