im testing my game on iphone5 simulator
i have background sprite with 1136*640 pixels size image
if i set my background with,
background1.anchorPoint=CGPointZero;
background1.position=ccp(0,0);
cocos2d magnifies that image.
if i set my background with,
background1.anchorPoint=CGPointZero;
background1.position=ccp(0,0);
background1.scale=0.5;
image fits screen, which is perfect. but if i do so then i get wrong background.contentSize , is that magnification of sprite stoppable?
i'v also set [director enableRetinaDisplay:NO];
It's probably because you haven't named the sprite with the -widehd extension. Like: background-widehd.png OR -iphone5hd depending on your version of cocos2d. If you targeting retina displays you should:
[director enableRetinaDisplay:YES]
Related
I'm building an app which uses Qt5 that aims to display a video from a digital camera (using Gstramer pipeline). Then with the help of QPainter I'm drawing some graphics on top of it (some text shapes, and icons).
The thing is that the video refresh rate is ~30 FPS, and I only need to update the graphics in ~10 FPS or so. Currently I redraw the graphics overlay for every video frame which is very wasteful in terms of CPU.
Is there a better approach in which I can re-use the overlay from the previous frame, and only update the background (the frame from the camera)?
One idea that I had was to paint the overlay into a QImage, and then just paint the image onto the QOpenGLWidget, but it just feels wrong.
Thank you...
I have a game I'm currently working on, and it uses multiple views (for a minimap for example).
Thing is, I would like to have a fading effect added at some point, so I thought I'd create a black image that is the size of the screen and change its alpha value with a timer. That part is not a problem.
What happens right now is the main area (ie window default view) is fading (because the opacity of the image is increasing), but the minimap (minimap view) is unaffected. This is normal behaviour for views, but is there a way to draw an image to the whole window, regardless of the views ?
Thanks in advance
To clarify, you have the default view where you'll draw the main game, then you'll have the minimap view where you would draw the minimap. At some point in the game you want the whole screen to fade to black. It sounds like you've been trying to draw a black image on the default view (changing the alpha) to make this effect work.
So, you need a third view that you draw your black image on to get this fading effect.
I'm using TexturePacker to generate sprite sheets. I have images sized perfectly for retina iPhone, I'm using AutoSD feature in TexturePacker to pack them to sprite.png and sprite-hd.png. Both png files look sharp. When I test my game in retina emulator it looks crisp, everything's fine. However when I run 480x320 iPhone in emulator and my regular sprite.png loads - sprites look blurry.
When I manually resized all my individual sprite files and created a sprite sheet from them using TexturePacker it looked fine too.
I was hoping TexturePacker would save me some time doing things manually, and I can't understand why my sprites look blurry. Please help.
I am building an OpenGL application. I read through the GLUI tutorial on Code Project to create windows form controls on an OpenGL Application. But my requirement is to develop a color choser/picker, like an RGB chart or RGB cube to select a color. The tutorial on Code project shows the list of colors as a drop down box. However that wont really help me, as I require it to be present as a windows color picker. I know that color picker as a dialog box is a part of the windows application. Can anyone suggest me a way to use it with my OpenGL Application?
You can try fox-toolkit. It is a C++ based Toolkit for developing Graphical User Interfaces. It provides Color Picker and OpenGL widgets for 3D graphical manipulations.
On windows, you can call directly ChooseColor() from the windows API. It will open the native color color chooser.If you need a cross-platform solution, tiny file dialogs on sourceforge also has a color picker and no main loop.
You could render a Quad/Triangle/Cirle with different color on each vertex and activate smooth shading for interpolation between these points. Then just read back the color value from OpenGL at the mouse position.
edit: or like that where you calculate the color on the mouse position by yourself (reading values slows down OpenGL a lot!): http://sharathpatali.wordpress.com/2009/07/07/a-color-picker-for-pymt/
I did this with simple gradient image which i kept in memory. Then i just tracked my mouse position on the image, and simply read the data from the image (that was kept in RAM) and get the 32bit RGBA color value for it. This is easier than reading the pixels from screen (also faster and more reliable).
This also allows a lot more flexible way of presenting the palette, only your imagination is the limit on the looks of your palette. Note: you must use 32bit colors on the image, because if you want smooth edges, you simply just fade the alpha but keep the colors the same, so the colors wont get distorted at edges. Don't forget to enable blending when rendering the image.
I want to animate the way a CCSprite appear on screen.
At the moment I'm using "addChild" to display the sprite on screen but I want it to appear on screen with animation.
Is is possible?
Thanks
Try reading through the Cocos2D programming guide, there is a subject on animation with source code there. http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:index.