Observed one serious Cocos2D Font related problem
Please see this image:
In above image, fonts are not rendered proper. I used CCLabelBMFont. How can I resolve this problem?
Code:
CCLabelBMFont *userName = [CCLabelBMFont labelWithString:PlayerNameStr fntFile:#"MyFont.fnt"];
You need to leave more space between the glyphs. You can change this setting in the bitmap font editor, Glyph Designer and Hiero both have it. In Glyph Designer the setting is called Spacing and set to 2. I'm guessing you're using Hiero which has this spacing set to 0 by default.
Related
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]
I have a splash screen image that I display with splash.showFullScreen() but it doesn't re size it to the screen resolution so it either comes out tiled or to large depending on the display. I have tried everything I can think of but nothing works. This might sound like a stupid question which it probably is but I can't find the answer so if any can just help me with this? If it makes a difference I use a QPixmap named pixmap for the splash image. By the way I want the image to be stretched to the screen resolution.
You should scale the pixmap to the size of the screen with QPixmap::scaled(). You can get the screen resolution by calling QDesktopWidget::screenGeometry(). The desktop widget can be obtained by QApplication::desktop().
You can try something like this:
QDesktopWidget* desktopWidget = qApp->desktop();
QRect screenGeometry = desktopWidget->screenGeometry();
int screenWidth = screenGeometry.width();
int screenHeight = screenGeometry.height();
QPixmap pixmapForSplash = yourPixmap.scaled(screenWidth, screenHeight);
QSplashScreen splashScreen(pixmapForSplash);
(I'm sorry, I can not check this, because I do not have a development environment on this computer... I hope it is correct.)
I think you should call resize() method for your splash screen by the size of the available desktop geometry that you can get using QDesktopWidget::availableGeometry method. The QApplication::desktop() function is used to get an instance of QDesktopWidget.
slpashScreen.resize(QApplication::desktop()->avaiableGeometry().size());
If you use a QLabel to display the image, make sure the label is in a layout that will cause it to fill the entire parent widget and set the label to scale its contents using setScaledContents(true).
i've implemented a owner draw button into my win32 app (no MFC). The button is a normal 20x20 bitmap (round icon with transparency). The problem is that the button is positioned on a solid background and i can see the buttons gray background (since the bitmap is round). I've tried responding to WM_CTLCOLORBTN with NULL_BRUSH but no luck.. I've tried displaying the button using a bitmap and a ico file but wont budge.. Does anyone know how to solve this problem?
This is my problem, the settings icon should be transparent at the edges (not white/gray)
It sounds like you're trying to make a non-rectangular control.
You could call SetWindowRgn to tell Windows that your control is non-rectangular.
In addition to what #joel's answer, if you want to make some area transperant put a unique color in the area where you want to have transperancy using some image editors (RGB(0xFF,0x00,0xFF)) is mostly used Then use TransperantBlt
You say it's a solid background but your image shows some kind of orange-yellow gradient as a background. If it really was a standard windows button solid color you can load the bitmap with LoadImage using the LR_LOADMAP3DCOLORS or LR_LOADTRANSPARENT. Since you have a gradient you'll have to use a more complicated technique to mask out the bitmap.
http://www.winprog.org/tutorial/transparency.html
I've followed the steps from this question:
Higher color depth for MFC toolbar icons?
The code works. But I have another problem - any disabled buttons are just grey boxes.
Once they are enabled - they are exactly as they should be.
I suspect that the CToolBar doesn't know how to grey out the supplied images - can anyone help?
thanks in advance.
CToolBar actually accepts up to three imagelists each to handle the normal, disabled and highlighted states of the button.
To accomplish what I need - just normal and disabled button states. I need two images. One with normal coloured icons and the other with greyed out icons.
Add the images as Bitmap resources to your project - amend and make note of the IDs
Create two imagelists and set them accordingly: (m_wndToolBar is the toolbar in my project)
CImageList imgListActive;
CImageList imgListDisabled;
/* Load your CImageLists */
m_wndToolBar.GetToolBarCtrl().SetImageList(&imgListActive);
m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(&imgListDisabled);
To set the highlighted versions of the toolbar:
CImageList imgListHighlighted;
/* Load your CImageList */
m_wndToolBar.GetToolBarCtrl().SetHotImageList(&imgListHighlighted);
et voila!
Usually two things are necessary to get the high color buttons and the correctly greyed out images:
Always edit the .bmp file for the toolbar outside of VisualStudio.
Add the images to MFC using a call to CMFCToolBar::AddToolBarForImageCollection(IDR_MAINFRAME); in your InitInstance() implementation.
Unfortunately this also means that you have to edit the Toolbar definition directly in the .rc resource file of the application.
I've got an MFC application that is built with VC6. When ClearType is enabled (Windows XP) some texts are rendered smoothly, i.e. with ClearType, and others are not.
Dialog texts don't seem to ever get rendered with ClearType. Some list controls, however, have it enabled completely, others only in their headers.
What could be the reason for this? Where should I look to find out why it works only in some places and doesn't in others?
Update
As requested, here is an enlarged screenshot. Obfuscated but the important parts should be visible.
In List 1 only the heading is smooth, the content is not.
In List 2 both, heading and list items are smooth.
The Dialog at the bottom is not using ClearType either.
Bitmap fonts will never use ClearType. Usually you won't use a bitmap font, but I believe the default selected into a DC is the System font, which is bitmap.
ClearType is a quality property for fonts. You should get the LOGFONT for your CFont and set the lfQuality property. Here's an example.
CFont *pFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));
LOGFONT logFont;
pFont->GetLogFont(&logFont);
logFont.lfQuality = CLEARTYPE_NATURAL_QUALITY;
CFont font2;
font2.CreateFontIndirect(&logFont);
Note: you can use either CLEARTYPE_QUALITY or CLEARTYPE_NATURAL_QUALITY, test both to see which looks best.