Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17114

Help me with scale factor positioning in other devices. Have black area from left and right side out of the glview and want to fill it with picture

$
0
0

@uvladus wrote:

Hello everyone. I am developing my game. All graph resources were made with resolution 1024x768 and second package 2048x1536. So I can cover ipad2 and other retinas ipad models. But when I ran it on android device 1280x800 with ExactFit I had it centered. GlView start pos was with offset.
image what I have
image what i want
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::EXACT_FIT);

Sorry I am new user I can not upload screens to topic. I could not draw any preety borders out of the glview to fill black corners from left and right side of glview.
cant draw out of gliview wheh mode is ResolutionPolicy::EXACT_FIT
I decided to make

static cocos2d::Size designResolutionSize = cocos2d::Size(1024  , 768);
...
Size winSize = director->getWinSize();
glview->setFrameSize(winSize.width, winSize.height);
glview->setDesignResolutionSize(winSize.width, winSize.height, ResolutionPolicy::NO_BORDER);
director->setContentScaleFactor(designResolutionSize.height/winSize.height);

So in this case I have fully access to whole resolution of non standart resoulution device and I could fill any area of device resolution. All graph resouces are scaled normaly but positioning is bad. Why is ContentScaleFactor does not take affect to positioning. For example

button->setPosition(Vec2(100, 100));

here position of button takes real position 100;100. ContaintScaleFactor does not take affect on it. I have to multiple on it to see right value

button->setPosition(Vec2(100 / director->getContaintScaleFactor(), 100 / director->getContaintScaleFactor()));

Also I have many csb files which are with the wrong positioning. I understand if I set my glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); I would have normal positioning but I wont been able to fill left and right corners of glview.
Example on ios 5. designResolution set to 1136x640 glView frame is 1136x640. _contentScaleFactor is 1.2 because 768/640 = 1.2. All graph resources scales normaly, but positioning is bad. Look where are the buttons play options and info
I want to make my game scenes offset on x coordinate to set it in the center and fill black rects from the left and right with preety picture border. How can i do this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17114

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>