how to adapt my cocos2d-x app on iphone 5 - ios6

My game is designed with cocos2d-x, the picture resource size is 320x480, which is adapted to iphone4, now I want my game adapt to iphone5, what should I do?, thanks!

It actually depends on your current cocos2d-x version and the resolutions you're planning to support. But basically if you're running the latest stable release (2.0.4) and you only want to support iPhone4 and iphone5 resolutions then you have to:
create the art for both resolutions (this is not mandatory but the graphics might be scaled too much and lose quality).
define at runtime the DesignResolutionSize and ContentScaleFactor based on the actual device's resolution
select the correct resource path
Here a simple example on how it can be implemented:
// Get the real screen size
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution. Please see the doc for the different modes
pEGLView->setDesignResolutionSize(480, 320, kResolutionNoBorder);
// Here you have to chose between width or height depending your game's design
if (frameSize.width > 480) {
// iphone5
pDirector->setContentScaleFactor(1136/480);
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
} else {
// iphone4
pDirector->setContentScaleFactor(1);
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
}
/// Now load the sprites....
If you're want to support more iOS/android resolutions please refer to the following links for fullscreen multi-resolution solutions offered by cocos2d-x:
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Mechanism_of_loading_resources
Hope it helped.

Cocos2D-x 2.0.4+ have very easy solution for multi-resolution problem. ( either iDevices or Android devices.)
In fact you just need to set your DesignResolution and then just imagine your target device will has this resolution.
If target device really has this resolution ( or some other but with same ratio) cocos2d will handle to fix screen and your game looks same in all devices.
And when ratio of target device is different, you have many option ( as cocos2d language, policy) to manage that.
For example if you use Exact fit policy, cocos2d will force your game ( and design) to fit target device screen (without that black boarder).
Exact fit
The entire application is visible in the specified area without trying
to preserve the original aspect ratio. Distortion can occur, and the
application may appear stretched or compressed.
For more detail just take a look at this link : http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

Related

how to display lightmaps in the appcreator

running on macbook iOs X(yosemite) and chrome browser,
i try to view an archilogic model:
Model Used
in https://appcreator.3d.io/
but the result doesn't seem to display the same lightmaps mapping on interiors:
https://app.3d.io/lLOkYR
This might be due to the fact that the lighting system in spaces editor is a different one than the lighting system in aframe. I recommend you to adjust the lighting in your aframe scene using the following parameters (search for these values inside your html code in the app creator):
lightMapIntensity: 1.887; lightMapExposure: 0.55
also you can adjust overall lighting intensity by modifying:
<a-scene io3d-lighting="intensity:0.9">

Rendering problems when saving multiple Dygraphs as a PNG on mobile devices

I have a web application that uses Dygraphs to create charts.
The application allows a user to create multiple Dygraph charts (each with their own Y-Axis) that will be stacked on top of each other.
Here's an example of what the multiple Dygraphs look like on a PC browser: Notice that the example displays three different Dygraphs each having their own Y-axis, but the X-axis is hidden for the top 2 charts and visible on the bottom chart.
I will allow the user to save the chart to disk as a PNG. - The way I currently save the multiple Dygraphs as one PNG is:
Create a target canvas that will be used to contain all the visible Dygraphs
Extract each canvas out of each Dygraph, then add each canvas to the target canvas **
Create a PNG via the .toDataURL() function on the target canvas
Here's an example of what the above screenshot looks like when saved as one PNG: (This is exactly what I want from the PNG)
The procedure works fine on browsers on a PC. But when I attempt to save the multiple Dygraphs into one PNG on a phone/tablet browser, the resultant PNG doesn't match the graph that is visible on the screen.
Example:
Here's what the multiple Dygraphs look like on an iPad (screenshot)
And here's what the resultant PNG looks like (Notice how the width and height of each chart does not match the actual iPad display).
I don't understand why the PNG is rendered correctly when I use a PC browser, but is not rendered correctly when I use a browser on a mobile device.
I'm not sure if this problem is due to limitations of the Canvas.toDataURL() function or if this is a Dygraphs problem or something else. I'm fishing for advice that may point me in the right direction and/or shed light on this particular problem.
**I should mention that I use Juan Manuel Caicedo Carvajal's Dygraph-Export extension
I'm guessing the Problem occurs, because the generated canvas isn't rendered fully to the responsive screen of an iPad.
You can try to export the original canvas (instead of generating a new one with the said library) yourself with toDataUrl https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
Dygraphs generates 2 canvas, one for the legend and one for the actual graph and lays them ontop of each other. So make sure you choose the right one (not the _hidden_canvas). If the examples works you can draw the legend onto the graph canvas with canvas.drawImage(otherCanvas)
How to Copy Contents of One Canvas to Another Canvas Locally
Hope this helps. Keep me updated!
My workaround/hack for the problem stated in my OP was to make a change to the Dygraph source in the Dygraph.getContextPixelRatio function.
Notice in the code below that I set devicePixelRatio = 1
dygraph-combined.js
Dygraph.getContextPixelRatio = function (context) {
try {
//var devicePixelRatio = window.devicePixelRatio;
var devicePixelRatio = 1; // Hack!!!
var backingStoreRatio = context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
if (devicePixelRatio !== undefined) {
return devicePixelRatio / backingStoreRatio;
} else {
// At least devicePixelRatio must be defined for this ratio to make sense.
// We default backingStoreRatio to 1: this does not exist on some browsers
// (i.e. desktop Chrome).
return 1;
}
} catch (e) {
return 1;
}
};
In my case, this hack fixed my problem (stated in the OP) and didn't negatively affect any other parts of my application that uses Dygraphs. That said, if you find a better/correct way to fix the problem stated in the OP, please share.

Online Maps (google, nokia)

Is it possible to highlight a list of countries with a different colors?
I need to display some countries' statistics on the world map.
Now I use an image and fill a region with color (calculated for each country) by country's coordinates. It's a simple solution and it works well. But now I need to specify the countries' name too (and I think it's not the last customization).
There is a polygon solution, but it uses an array of coordinates. I don't think it's a suitable solution to highlight countries's territory.
I haven't found a solution yet. Any suggestions?
Thanks in advance.
Highlighting countries or regions to support statistics is known as Choropleth Mapping
, but unfortunately there usually isn't direct library support for Choropleth maps bundled into an online map API. This means you'll have to create your own framework, but fortunately it is possible to create one - I wrote an example using jQuery + HERE Maps to
answer the question here
Updated WKT solution now available
Access to KML shapes is no longer required, since the Geocoder API now offers an IncludeShapes attribute which returns the shape of a country in WKT format. A WKT parser can be found here.
A simple WKT choropleth example can be found here.
KML Base solution
For any framework you will need to have a file holding the boundaries of the countries or regions you need. The example uses a KML file, but you could also start with polygons if you had them. Country borders are a political minefield, which is the reason I guess most online mapping APIs steer clear of them. As a hint: try starting with something like http://geocommons.com/overlays/119819 and simplify it as much as possible to speed up the rendering- many small wiggles in the coast lines and small outlying islands are unnecessary.
Of course you could also try searching for "create choropleth map" from a search engine of your choice and use an tool to create a static image for your data (potentially at several zoom levels) and then use this as the basis of an map tile overlay. This requires a lot more work up front, but would push all the calculations server side and hence be faster to display.
Working example can be found on GitHub here
You could put the country's name into the image. It's not that difficult to place text into an image. The only tricky bit is if you are using tiles, you need to deal with names that cross tile boundaries by drawing the name once for each tile.

mobile device resolution and browser viewport size

I got galaxy nexus with resolution is 720x1280. But when I call $(window).width() it just return 360px. Are there anyway to calculate value of $(window).width() on other devices? For an example, galaxy s 480x800? I need those values for my media queries:
#media only screen and (min-width: 360px){
body{
font-size: 62.5%;
}
}
I don't know if you're going to like my answer.. but here goes.
Forget about width (fixed widths at least), and make your website device-agnostic. Don't base your breakpoints on popular device resolutions, instead base them on your content. Keep stretching that browser window until you get that gut feeling that says "that doesn't look right" - that's your next breakpoint.
Keep it as fluid as you can and rely on relative units - even on your media query declaration.
I suggest giving this article by Chris Armstrong a read: http://www.alistapart.com/articles/the-infinite-grid/ (although ALA appears to be temporarily offline)

How do I add an "enviroment" to my scene in 3ds MAX?

I'm Currently working on a scene and i cant seem to find infomation as to how to make a setting for my scen. Its basically a street with buildings on either sides. about 500m long.
I want to put it into a city "enviroment" for animation. Also there will be camera movements so i dont think simply adding an image as a background will work. what i want to know is, Is there a a way to achieve what i want without actually building a small city?
any help or a pointer in the right direction would be great.
thanks in advance
A cubemap might work. http://wiki.polycount.com/CubeMap
There are applications which will generate a city for you, based on criteria you enter. You can enter the building types, sizes etc. I've used one called City Engine - I used the built in wizards to create this but you can create one from scratch even specifying the road layouts: Youtube Video
3ds max has predefined models within it's system,
For example a tree:
This tutorial is great:
http://www.youtube.com/watch?v=G-cfF2ep2DI
look into "AEC Extended"

Resources