cocos2d-x FIXED_WIDTH isn't working - cocos2d-x-3.x

I have a 700x1280 image and my design resolution is 700x1280.
I am not providing separate assets for each device that I target rather i will use one Resource which contains all my assets.
The problem:
When I set my design resolution I pass a ResolutionPolicy::FIXED_WIDTH meaning from what I understand it will scale the width with no bordering but the height may be bordered. But all I see is a fixed width but the height of the image goes out of the screen i.e it's not making the height fit in the screen like FIXED_WIDTH is supposed to do?

FIXED_WIDTH only promises to keep the width using the full physical width of the screen but doesn't promise that the height will stay the same i.e it may go out of the screen. For portrait mode FIXED_HEIGHT is the way to go because your height on any device is definitely bigger than that of the width so by using FIXED_HEIGHT the width will never go out of screen, it's a bummer but that's what you have to do!

Related

How to keep the same resolution of canvas on different screen resolution?

First of all, sry for my English mistakes, I'm not a native English speaker.
I'm trying to make an UI which is composed of a canvas within different gameObject, and I would like that my canvas scales to the dimension of the screen but keeps its original resolution (16x9 portrait). If it is displayed on a tablet resolution (4x3) then an image is displayed in the space that is not covered by the canvas.
But actually all I've got is a canvas which scales to every resolution, and it changes the aspect of its child (for example a square becomes a rectangle).
Thank you for showing interest in my query!
UI's are heavy beasts. Canvas in Unity have a component attached to themm called Canvas Scaler which is set by default on Constant Pixel Size. You may try to set this property on Scale With Screen Size and then specify the base resolution you want to work with (usually 1920x1080 is a console standart). This is your first step
Then, to avoid strange Image scaling, you may check the property Preserve Aspect, this way the ration of the Sprite into your Image will remain the same indepently of the ratio of the Image
Last, you may play a bit with anchors but this is another story, you should let those at plain center at the beginning and come back to it when you will feel ready
Hope that helped ;)
Your canvas should have a component called Canvas Scaler. Here it should say Constant Pixel Size, change this to Scale With Screen Size and it should lock the Canvas to be the same width / height as the screen. If you want to lock an image to a specific width/height ratio, go to the Image component on the image and check the Preserve Aspect checkbox. This way if you have a 100x100 image, the images width will always be the same as the height. If you have a 200x100 image, the images width will always be twice the height, etc etc etc.

Set Constraints of Image using XCode 11

I'm trying to constraint one dog image so that it is centered vertically in the container, which I can do. What I can't seem to get it is having it just above the halfway horizontal point. So I want it to be a certain fraction down the screen (say a third) on any device. I also want the size of the image to be relative to the screen size.
I want the image to be about what it is in the image but maintain its proportions relative to the device of the user.
I've tried tons of things and none of them work. Any help is appreciated.
Here's the Image
Create an UIView and set the image to fill the UIView. After that make the UIView top constrain equal to the centerY anchor which makes the UIView below center horizantal. By using layout anchors for width and height ( not fixed hard coded numbers) you will make it's size relative to device size so doesn't matter using any device type. Post a graphical design if you need more specific answer.

How do I set specific y position, width and height without diving into code?

A designer I'm working with wants to have a UIImageView be at a specific y position, with a specific width/height depending on the iphone size. I've done research and I haven't been able to find anything online that allows me to do so with constraints on the story board. I want to avoid having to use code because throughout the rest of the app there are a lot of similar situations. In the past I've made different storyboards for each phone size to accommodate for the specificity our clients request, but I want to avoid doing this because it feels like bad practice. Is this even possible?
This can be completely handled in the Interface Builder. Follow the steps below.
1) Add your UIImageView to the ViewController
2) Set constraints for Width, Height, Vertically Align and Horizontally Align
3) You can adjust the Y position in the Size Inspector of the view.
4) Now switch to Assistant Editor and choose 'Preview' and add different screen sizes to see the auto layout in action.
All of this will set a static image size of 250x200, horizontally centered, and vertically at 1/4 of the screen height.
Little-known capability of constraints are that you can set view positions, or in your case sizes, by way of ratios against other views.
With just your image view selected, the tie-fighter :) constraints button lets you specify absolute positions & sizes: do that to set your desired y-position. But then select both your image view and its enclosing parent view, then the pop up for that same button now enables the equal height/width buttons. Add those constraints and then edit the constraint to change the 1:1 ratio to whatever ratio you need.
Excuse my lack of screenshots, posting from my phone.

Some slides portrait, some landscape - how to get Jssor to display them correctly?

My slides are different sizes, and orientations (some panoramas). I mean all are pics from a photo roll. Nearly all pics are bigger than the viewport in one way or another. I want them to be centered, have a correct aspect ratio, still have touch controls for iPhone, as well as the < > widgets (which go invisible by the way if the image is narrower than the width of the page) for desktop.
I can get full width, by specifying max-width in CSS. Full height is trickier. The "Full Width Slider" demo fixes height at 500px, and trial and error only allows me to change that to another integer number rather than a percentage.
So I'm struggling to tweak the right options, and set the right style/css inline in the HTML. Is there a better demo for me than "Full Width Slider" (http://www.jssor.com/demos/full-width-slider.html)
It'd be great to pinch-zoom into images that are larger than the viewport, but that's secondary to getting my "fit" issues sorted :)
Please set slider size to your screen size, and set $FillMode to 1.
To apply css tricks to set slider size, you can place jssor slider in a wrapper, and then scale the slider to available width of the wrapper.
See,
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$ScaleWidth(parentWidth);
else
$JssorUtils$.$Delay(ScaleSlider, 30);
}
Reference: jssor full height or full screen slider / possible?

Fixed camera width instead of height?

Is it possible to keep the camera width fixed instead of the default setting: height?
Making the height fixed is causing problems for my mobile game (vertical) on multiple devices. Is it possible to change this behavior of the camera?
Thanks
This has to do with the different aspect ratios. I don't think there is a fixed height, the screen just adopts to the given ratio.
If you want to achieve a fixed aspect ratio this unify page will probably help you, it will fill the screen with black bars of devices not fitting your ratio:
http://wiki.unity3d.com/index.php?title=AspectRatioEnforcer