CCLabelBMFont fnt file not working properly - cocos2d-iphone

so I have this:
CCLabelBMFont *timeLabel = [[CCLabelBMFont alloc] initWithString:#"abc" fntFile:#"clean_3.fnt"];
in a CCScene init method
using this font: http://fontstruct.com/fontstructions/show/clean_35 which is TTF
using this program to convert the format: http://www.angelcode.com/products/bmfont/ and tried http://www.n4te.com/hiero/hiero.jnlp .
I'm getting: "Invalid texture for sprite" error.
I have tried deleting the app off simulator and device and tried it again, same thing.
Any help would be appreciated. I do not want to use CCLabelTTF since I'll be updating this text every frame.

Looks like I forgot the PNG file. Thanks ubert!

Related

QMediaPlayer is unable to play song on Window

Hello Techie's I am working on Qt QMediaPlayer and trying to play song through my local file but i don't know where I am getting wrong I am unable to play song on Window but the same code is working fine in Mac but not on window.
For all kind helps Thanks in advance.
I had tried this
player->setMedia(QUrl::fromLocalFile("<path to file>/test.mp3"));
and this as well
player->setMedia(QMediaContent(QUrl::fromLocalFile("<path to file>/test.mp3")));
Here's my complete code snippet:
QMediaPlayer *player = new QMediaPlayer();
player->setMedia(QUrl::fromLocalFile("<path to file>/test.mp3"));
player->setVolume(100);
player->play();
qDebug() << player->errorString();
No error listed, so its difficult to identify where I am getting wrong.
Have you try some path format, i had a similar experience with QMediaPlayer and i had to use path format like this some\\path\\exemple.mp3 or like this some//path//exemple.mp3 i don't remember exactly.
Maybe check QMediaPlayer exemple and try to run the exemple to check if is codec problem or a code problem.

Getting wxStaticBitmap in BoxSizer

I try to ask not to localized, because I think many other wxWidgets users will stumble about this problem or a similar one.
I try to get a wxStaticBitmap (original a PNG-Image) in a GUI, I will try to model it:
text text text
text text text
IMAGE
text
text
How I can do this? When I try:
wxBitmap bild(_T("Bild.png"), wxBITMAP_TYPE_PNG);
wxStaticBitmap *image = new wxStaticBitmap(this, wxID_ANY,
wxBitmap("Bild.png", wxBITMAP_TYPE_PNG),
wxPoint(100,100),
wxSize(bild.GetWidth(), bild.GetHeight()));
The image will take over the hole window, even the wxNotebook, which contains the wxPanel, will disabled and I have only the image, but nothing else...
I want to get the image in the third row of the VerticalBox. Is there any way to make this happend?
-Casisto
(wxW: 2.9.4; C++-Compiler: g++)
There is nothing special about wxStaticBitmap and you absolutely don't need to put it inside a panel. You do need to create it with the correct parent, if this in your example refers to wxFrame, it's not going to work if you then put it inside a wxPanel sizer, for example.
P.S. Do get rid of _T in your code, it's completely unnecessary in 2.9+. You also probably don't want to load the bitmap twice...
Ok, i found the answer myself:
I've to use a "subpanel" which will be the parent of the StaticBitmap
so it's this structur:
panel << vbox << Text
vbox << panel_2 << Image
vbox << Text

Cocos2d-x runAction Error

Okay, so I want my cat sprite to move up and down onClick of two (UP and DOWN) buttons.
I'm a beginner in cocos2d-x.
So, in mygame.h i have a global declaration of the sprite cat:
cocos2d::Sprite *cat;
In one function i create a new scene and add a cat in it.
cat = Sprite::create("cat.png");
cat->setScale(0.2);
cat->setPosition(0, 190);//(Director::getInstance()->getVisibleOrigin().x + 50, Director::getInstance()->getVisibleSize().height / 2);
layer->addChild(cat);
playscene->addChild(cat);
In another function(button callback) i have this code:
void HelloWorld::down(Object* pSender){
CCActionInterval* down = CCMoveBy::create(1.0f, Point(0.0, -20.0));
cat->runAction(down);
}
And everything's ok untill i press the up or down button.
It throws an error on the cat->runAction(down); line.
When i exemine the variable cat, it looks like I cant get to the position parameters. Its a memory read error..
In cocos2dx 3.0
you can write direct in runaction for any sprite.
spriteName->runAction(Sequence::create(MoveBy::create(1.0f,Point(398,565)),NULL));
It looks like you are mixing Cocos2D-X 2.x API's with Cocos2D-X 3.0 ones. I'm taking a stab in the dark guess and saying it looks like you're trying to use 3.0. You will need to change the following line:
CCActionInterval* down = CCMoveBy::create(1.0f, Point(0.0, -20.0));
To:
ActionInterval* down = MoveBy::create(1.0f, Point(0.0, -20.0));

Cocos2d-Android Custom font not working

I am trying to use custom font in Cocos2d-Android with CClabel, I have added my font file into the assets and trying to use it by name "Faraco_Hand.ttf" and "Faraco_Hand" but its not working, I have googled around but haven't found any solution. this is how my code looks a like:
currentVideoLabel = CCLabel.makeLabel(VideosLabels[currentSelected], "Faraco_Hand.ttf", winSize.width/41);
currentVideoLabel.setPosition(CGPoint.make(winSize.width/2, 20));
addChild(currentVideoLabel);
If someone know this please help me.
Hi i use this way to add font in my game here i am sharing you my code check it hope it's helpful for you here i am setting my font on label this is the only way to set fonts...all the best
Example:1
CCLabel labelcontinue = CCLabel.makeLabel("continue", "fonts/JimboStd-Black.otf", 14);
labelcontinue.setPosition(CGPoint.ccp(272, 95));
labelcontinue.setColor(ccColor3B.ccc3(165, 42, 42));
mainPaperNode.addChild(labelcontinue, 25);
Example2:
CCLabel labelWelcome = CCLabel.makeLabel("Welcome", "fonts/JimboStdBlack.otf",20);
labelWelcome.setColor(ccColor3B.ccc3(139, 69, 19));
labelWelcome.setPosition(CGPoint.ccp(innerArea.getContentSize().getWidth() / 2, (innerArea.getContentSize().getHeight() / 2) + 138));
innerArea.addChild(labelWelcome);
i know this is late reply, anyhow it may help someone who search this same thing...
CCLabel supports external fonts but some of the ttf will not recognized by android so it will through exception so better you try another font instead of this the code is same...
label = CCLabel.makeLabel("label value", "external_font_name.ttf", 30);
label.setPosition(CGPoint.make(winSize.width/2, 20));
addChild(label);
I don't think there's any problem with your method. I guess the problem is you are renaming the original font file. Rename the font file name with its original name (written in the font file itself, check attached image).
in this case, I kept my ttf file in Resources/fonts folder and wrote my code like:
CCLabelTTF* label = CCLabelTTF::create("Hello World", "fonts/A Damn Mess.ttf", 20);
Also check CCLabelTTF instead of CCLabel.
Hope this will help you.
Hai this will help. This code works for me fine. Put custom font int assets->fonts
CCLabel label1 = CCLabel.makeLabel("Points: 0", "fonts/pin.ttf", 28);
label1.setColor(ccColor3B.ccWHITE);
label1.setPosition(280f * scaleX, 550f * scaleY);
addChild(label1);

CCLabelBMFont Label takes long time to load!

I have a game. In game there is a help text. The game menus are transitioned on sliding in and out manner. Like if you click "Help" button on "Main Menu", Main menu slides out and help menu slides in.
Now i got problem while loading "Help Menu". The help menu consists of a scroll view and help texts are loaded in scrollview when it is initialized. The Text in Help Menu are CCLabelBMFont Label. The help text has multiples lines (upto 146) lines. My problem is when I click on Help menu, the sliding In takes up to 10 secs to come up. I know it's due to the long help text that is created using CCLabelBMFont.
Is there any solution of this case. When I decrease the lines of help text to 50, it works fine. I directly created the label with following code in HelpMenuLayer.m
CCLabelBMFont *contentLabel = [[CCLabelBMFont alloc] initWithString:#"Objective:"
"\n........."
.
.
.
fntFile:"fontFile.fnt"];
contentLabel.position = ccp(0.0f, 0.0f);
[scrollview addChild:contentLabel]
[contentLabel release];
Any comments or suggestions are greatly appreciated. Thanks in advance. I really need help :(
I solved the above issue using png image. And wrote down in some steps in following blog of mine. Please visit following link.
http://learninprogram.blogspot.com/2011/06/solution-to-cclabelbmfont-bitmap-fonts.html
Thanks for everyone who tried to help me and helped me actually. Happy sharing!!
Well it is probably UIKit causing any slowness. Cocos2D and UIKit do not play well together in my experience.
Anyway I don't know for sure what is wrong. Here is my usage of CCLabelBMFont (which does not use UIKit but it should be the same):
CCLabelBMFont *multiplierLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:#"%i", [player scoreMultiplier]] fntFile:#"projectOneTitle1.fnt"];
multiplierLabel.position = ccp(winSize.width*0.9, winSize.height*0.95);
multiplierLabel.tag = 9845;
[self addChild:multiplierLabel];
That probably won't help, but in the off chance that it does I am posting it. Good luck.