CCLabelBMFont Label takes long time to load! - cocos2d-iphone

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.

Related

Add accelerator ctrl+F for text search

I am trying to add a Ctrl+F accelerator to my gtkmm textview program. I already implemented the search function into an gtk Entry field, so the only thing I need is to get focus the find entry when Ctrl+F is pressed.
I googled and checked tutorials/reference of gtkmm (2.4, I'm working with that) but the only things I found were accelerators in context with menus and toolbars using UIManager, which I don't have in that .cc file I use (and I can't add them, cause its an existing program).
I tried to add an action with an AccelKey on a button or tried the function add_accelerator() but I wasn't able to use them properly (I am pretty new to gtkmm and there aren't enough samples - at least none I understand). Here some examples I tried:
_gtkActionGroup->add(
Gtk::Action::create("find", "Find", "search in file"),
Gtk::AccelKey("<control>F"),
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
I didn't know how to add this action to the button (in the toolbar) I created...
_gtkAccelGroup(Gtk::AccelGroup::create()) //initialized in the constructor of the class
...
_gtkBtnFind.add_accelerator("find", _gtkAccelGroup, GDK_Find,
Gdk::ModifierType::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
I tried here something, but I didn't really understand neither the parameters I needed to enter here nor how this method works - ofc it didn't work...
I'd be really happy if anyone can explain me how this things work properly and sorry for my bad english. If there are any things you need just tell me please. Thanks in advance
Greetings
edit: I looked up in the gtk sources and tried to understand the parameters of add_accelerator. Now I tried this but still doesn't work...:
_gtkBtnFind.add_accelerator("clicked", _gtkAccelGroup, GDK_KEY_F /* or better GDK_KEY_f ?*/,
Gdk::ModifierType(GDK_CONTROL_MASK), Gtk::AccelFlags(GTK_ACCEL_VISIBLE));
_gtkBtnFind.signal_clicked().connect(
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
UPDATE:
Okay I have understood most I think now, and I know why it doesn't work. The problem is that I have to add the accel_group to the window widget, but I got only a scrolled window and boxes in my program....and now I have no clue how to continue... :)
UPDATE2:
Alright I managed to do it without accelerators by using the "on_key_press_event" handler by checking the state and keyval parameter. Hope this helps some ppl at least ^^.
bool on_key_press_event(GdkEventKey* event) { /* declaration in my constructor removed */
if(event->state == GDK_CONTROL_MASK && event->keyval == GDK_KEY_f
|| event->state == (GDK_CONTROL_MASK | GDK_LOCK_MASK)
&& event->keyval == GDK_KEY_F) {
_gtkEntFind.grab_focus();
}
return false;
}
I would be still interested in a solution with the accelerators if there is any ! Greetings

MFC: Delay when using GetContextMenuManager()->ShowPopup with Office2007 visuals

I'm having a problem when trying to show a context menu (resource) on a right-click at the systray.
I've detected that this line:
CMenu menu;
menu.LoadMenu(IDR_MENU1);
HMENU hMenu2 = menu.GetSubMenu(0)->Detach();
--> m_pTrayMenu = theApp.GetContextMenuManager()->ShowPopupMenu(hMenu2, point.x-5, point.y, this, TRUE);
Stalls the program for about ~1.5 seconds. Edit: But only the first time this code is being run.
However, it only stalls if I have this line:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
If I change that to Office2003 instead, it works (though it doesn't get the nice visuals that I want)
I've tried looking on MSDN and different forums but it doesn't say anything about *Office2007 non-compatible with ShowPopupMenu().
I'm out of ideas. Can anyone help me shed some light on this issue?
Best regards,
Anton.
I've gotten a response from the MSDN forums:
(after being taken to the devs, this is the response I got):
As per the devs this behavior is by design. The delay is mainly
because of some XML parsing being done to load the office colors. The
color details are stored in an XML resource file.
The thread can be found here:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/32d796a3-7b42-431e-9e1e-f58fb0dee0be/cmfcpopupmenu-and-cmfcvisualmanageroffice2007-not-a-good-match
Thank you all for your response and help.
My current solution is doing this:
CMFCPopupMenu *c = new CMFCPopupMenu;
delete c;
directly at the start of the program (thus having a ~1 second load before showing the main window).
Thank you all.
Best regards,
Anton.

wxPython - how to colour the text of a statusbar

I searched for the answer in the forum, but I didn't find anything, if I am wrong, I am sorry.
Anyway, question is simple, I have this Frame, with a Status Bar I use to print messages or notifies.
I would like to use it for mistakes or not permitted operations. But I would like these messages to be coloured. I am looking for a solution on wxPython demo -because i read somewhere on the web to get some inspirations by it-, but i still did not find anything.
Do you have any ideas or solutions?
thank you in advance.
I would try the SetForegroundColour or SetBackgroundColour methods of the status bar widget. These methods don't always work on every platform though as each OS has its own rules and wxPython follows those rules. If they do not work, then you'll have to roll your own statusbar, probably by using a couple of panels in a sizer or a splitter window.
There is also the 3rd party EnhancedStatusbar widget which might work for you. It can be found at http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
Simple solution: pin wx.StaticText on the status bar and write text in it. Text coloring in wx.StaticText works well.
For example:
self.sb = self.ws.CreateStatusBar()
self.sbtext = wx.StaticText(self.sb, -1, '', pos=(8, 4))
...
self.sbtext.SetForegroundColour(wx.Colour(color))
self.sbtext.SetLabel(text)

Orientation delegate method is not getting called while rotating the tabs under more section

In my project the tabs which are not under more section are properly responding to orientation but the tabs present under the more section are not responding.
For example if I am having two tabs names tab1 and tab2 under more section and if I am putting break point at the "shouldAutorotateToInterfaceOrientation" method of each tab.After that when if I am selecting tab1 from more section and tries to rotate it but the "shouldAutorotateToInterfaceOrientation" of the tab2 gets called.The delagate method of the tab which I am selecting is not getting called.I am working on XCode Ver 4.3.2.
Can someone please help me in solving this problem..
Thanks in advance,
Prajnaranjan Das
Please write followings code of all the root view controller of tab bar controller.
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return yes;
}
i face the same prblm as you facing now...
i was Return YES (shouldAutorotateToInterfaceOrientation Function) to all the view Controller classes inside tababarcontroller and my problem solved..
try to do this...might be you also get success
I used this method for orientation. Its working properly.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
}
There are several other methods which may help you in orientation such as:
• willRotateToInterfaceOrientation
• didRotateFromInterfaceOrientation
• willAnimateFirstHalfOfRotationToInterfaceOrientation
• willAnimateSecondHalfOfRotationFromInterfaceOrientation

How to remove animation from object?

How to remove animation from object in raphael?
var animation = Raphael.animation({opacity:.2}, 1000);
var circle = paper.circle(0, 0, 5).animate(animation.repeat(Infinity));
I want to perform animation on object until some moment in time. And the question is how to remove/stop animation in that specific moment?
Well, I really don't know why, but the fiddle works if don't pass any arguments to the stop method. Despite what Raphael's documentation says, I found a working example of an animation stopping in this site (is not the most beatiful site, by the way, but they have an example for each raphael method!)
Here you have the Fiddle working. http://jsfiddle.net/fKxqS/2/
Enjoy!
If you want to stop the animation after a specific timelapse...
setTimeout(circle.stop(animation), 500) //500 is milliseconds, so it's 0.5s
If you want to stop the animation after an event, such as a click
circle.click(function(){
circle.stop(animation)
})
Edit: Seems Raphael doesn't stop if repeat is set to Infinite, perhaps somebody knows a workaround, here's the fiddle: http://jsfiddle.net/fKxqS/