When in cocos2d-x you set ResolutionPolicy::SHOW_ALL then it might appear black areas from top-bottom or from left-right sides. Can I cover the black area with some nice images?
I don't think you can just add something into those back areas.
Instead the solution is to build a scene which already contain the nice images you want to add. The steps are:
Use this inside your AppDelegate::applicationDidFinishLaunching() to detect screen size:
CCSize frameSize = pEGLView->getFrameSize();
Set a design resolution proportional to this frameSize maintaining its aspect ratio.
Put your "content" in the mid. Then, you have to calculate where are the "black areas" and add sprites to cover them. Keep in mind that for different screen the holes can be different, so you need to do some maths there and properly cover different hole sizes.
So, doing ResolutionPolicy::SHOW_ALL sets the openGL view to that size. That's why that can't be done with that.
On the other hand, there are many ways to tackle this.
What i did was :
1. Don't set the ResolutionPolicy.
Use a layer for those nice images/effects.
Create a new layer in that same scene and set the width and height of that layer according to aspect ratio of your content. And make this as your primary game view.
Related
I have multiple scenes in my mobile phone, in one scene the aspect ratio must be 16:10(vertical), in other scene it must be horizontal. I set the aspect ratio via Unity's GUI, but when I do this, the other scene is 16:10 too. Is there a way where I can change the aspect ratio, from the code? When that scene is loaded, the aspect ratio changes.
So what you want to do is:
First go to this Unity Docs link and understand the use of canvas scaler and the options provided. Basically you can set the UI Scale Mode to Scale with Screen Size and set the resolution required. In my case I set it to 1920x1080 (see image below) so that each screen has the same resolution across scenes. Note that this must be applied to every canvas within the scenes.
This will allow you to configure any specific aspect ratio in terms of resolution across different scenes, as required. I hope this helps.
Screen.orientation = ScreenOrientation.LandscapeLeft;
Screen.orientation = ScreenOrientation.Portrait;
With these two codes I did, what I want to do. If the scene is playable horizontal, I used the first code, and for vertical, I used the second code. It worked like a charm
I have one image of house and in house there are several parts available but in only one image.
I want to paint all parts like red color for wall and black color for roof. But only one image i have so how it is possible to color different portions in one image??
Can i use cocos2d or anything else for this interesting stuff?
Thanks in advance.
You can fill different colors on different part of image by making different CGRect sprite on image to be fill but I am sure that it would not solve your problem as the house image must have different shape to be fill like circular ,triangular or rectangular.And using CGrect will give you filling of rectangular size only.
The best possible solution for this would be using different images as the part of house.There may be other ways also but they would be complex and problematic so try using more than one images as you can fill each image easily.
I was wandering how it's possible to create a large terrain in opengl. My first idea was using blender and create a plane, subdevide it, create the terrain and export it as .obj. After taking a look at blender I thought this should be possible but soon I realized that my hexacore + 8GB RAM aren't able too keep up the subdeviding in order to support the required precision for a very large terrain.
So my question is, what is the best way to do this?
Maybe trying another 3D rendering software like cinema4d?
Creating the terrain step-by-step in blender and put it together later? (might be problematic to maintain the ratio between the segments)
Some methods I don't know about?
I could create a large landscape with a random generation algorithm but I don't want a random landscape I need a customized landscape with many details. (heights, depth, paths)
Edit
What I'll do is:
Create 3 different heightmaps (1. cave ground (+maybe half of the wall height), 2. inverted heightmap for cave ceiling, 3. standard surface heightmap)
Combine all three heightmaps
Save them in a obj file or whatever format required
do some fine tuning in 3d editing tool (if it's too large to handle I'll create an app with LOD algorithm where I can edit some minor stuff)
save it again as whatever is required (maybe do some optimization)
be happy
Edit2
The map I'm creating is so big that Photoshop is using all of my 8GB Ram so I have to split all 3 heightmaps in smaller parts and assemble them on the fly when moving over the map.
I believe you would just want to make a height map. The larger you make the image, the further it can stretch. Perhaps if you made the seams match up, you could tile it, but if you want an endless terrain it's probably worth the effort to generate a terrain.
To make a height map, you'll make an image where each pixel represents a set height (you don't really have to represent it as an image, but it makes it very easy to visualize) which becomes a grey-scaled color. You can then scale this value to the desired maximum height (precision is decided by the bit-depth of the image).
If you wanted to do this with OpenGL, you could make an interface where you click at points to raise the height of particular points or areas.
Once you have this image, rendering it isn't too hard, because the X and Y coordinates are set for your space and the image will give you the Z coordinate.
This would have the downside of not allowing for caves and similar features (because there is only one height given for a point). If you needed these features, they might be added with meshes or a 2nd
If you're trying to store more data than fits in memory, you need to keep most of it on disk. Dividing the map into segments, loading the nearer segments as necessary, is the technique. A lot of groups access the map segments via quadtrees, which usually don't need much traversion to get to the "nearby" parts.
Variations include creating lower-resolution versions of larger chunks of map for use in rendering long views, so you're keeping a really low-res version of the Whole Map, a medium-res version of This Valley Here, and a high-res copy of This Grove Of Trees I'm Looking At.
It's complicated stuff, which is why nobody really put the whole thing together until about GTA:San Andreas or Oblivion.
I have been able to find a lot of information on actual logic development for games. I would really like to make a card game, but I just dont understand how, based on the mouse position, an object can be selected (or atleast the proper way) First I thought of bounding box checking but not all my bitmaps are rectangles. Then I thought f making a hidden buffer wih each object having a different color, but it seems ridiculous to have to do it this way. I'm wondering how it is really done. For example, how does Adobe Flash know the object under the mouse?
Thanks
Your question is how to tell if the mouse is above a non-rectangular bitmap. I am assuming all your bitmaps are really rectangular, but they have transparent regions. You must already somehow be able to tell which part of your (rectangular) bitmap is transparent, depending on the scheme you use (e.g. if you designate a color as transparent or if you use a bit mask). You will also know the z-order (layering) of bitmaps on your canvas. Then when you detect a click at position (x,y), you need to find the list of rectangular bitmaps that span over that pixel. Sort them by z-order and for each one check whether the pixel is transparent or not. If yes, move on to the next bitmap. If no, then this is the selected bitmap.
Or you may use geometric solution. You should store / manage the geometry of the card / item. For example a list of shapes like circles, rectangles.
Maybe triangles or ellipses if you have lots of time. Telling that a triangle has a point or not is a mathematical question and can be numerically unstable if the triangle is very thin (algorithm has a dividing).. Fix: How to determine if a point is in a 2D triangle?
I voted for abc.
I am using opengl in a tilemap editor. Storing the tilemap in GL_LUMINANCE32F format, then modifying it with opengl commands.
Now, I'm realising canvas size limitations are a burden for people drawing tilemaps. So how could I implement an infinite canvas? (such that expands and shrinks without user needing to explicitly trigger it to expand or shrink)
The expanding or shrinking of the canvas in need isn't hard, I can easily create another canvas, move the old canvas contents on it and remove the old canvas. Instead, what I have no clue of is that how could I get the canvas to detect when it can shrink, and how much can it shrink?
So I should detect how many rows and columns of zeroes I have in edges of my canvas.
Make the infinite canvas from tiles.
One idea that comes to mind is to find how much to shrink in X and Y directions separately by the following method: Render a rectangular 'margin' of, say, half the size of the canvas and use ARB_ occlusion_query to find out if it's empty. If not empty, split in half and repeat (i.e. do a binary search to find the right size). This takes log(N) steps, where N is the size (width or height) of the canvas, so it's pretty quick, if done every now and then.
Shrinking the canvas like you suggest would not be helpful to artists. Frequently they expand the area they're working just to have area to work with. There's also spritesheets which have blank area around the models that are required to work in the target program.
My suggestion is to grow as needed, but allow the artists to tweak the sizes manually when they wish to do it.