<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Tag: MenuItem - Recent Topics</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/menuitem</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 04:11:48 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/tags/menuitem/topics" rel="self" type="application/rss+xml" />

		<item>
			<title>Joe Henry on "MenuItem FadeIn glitch?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3413#post-20927</link>
			<pubDate>Mon, 14 Dec 2009 15:20:27 +0000</pubDate>
			<dc:creator>Joe Henry</dc:creator>
			<guid isPermaLink="false">20927@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey people,</p>
<p>I am making a simple game and in my first scene (my main menu scene) I'm trying to fade my menu items in like so:</p>
<p><code>settings = [MenuItemImage itemFromNormalImage:@"settings.png" selectedImage:@"settings.png" target:self selector:@selector(settingsScene:)];<br />
settings.position = ccp(-130, 210);<br />
settings.rotation = 340;<br />
[settings runAction:[FadeIn actionWithDuration:1.0f]];</code></p>
<p>I later add the settings object to a menu object.</p>
<p>My problem with this is that when I first launch my app the settings icon displays at full opacity and then it gets to the fade code so the icon disappears and then fades back in.  I'd like it to just start with 0 opacity and fade in.</p>
<p>Any answers are welcome =]</p>
<p>- Joe
</p></description>
		</item>
		<item>
			<title>msultakov on "MenuItem with dynamic text and image"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22082#post-122724</link>
			<pubDate>Mon, 24 Oct 2011 06:53:25 +0000</pubDate>
			<dc:creator>msultakov</dc:creator>
			<guid isPermaLink="false">122724@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello to everyone!<br />
I'm quite new to Cocos2d, so, please, don't be too strict :)</p>
<p>I need to display a menuitem which has a background, an icon and a text. Both icon and text are defined dynamically, so I cannot prepare an image that contains all the things I need.<br />
To be more concrete, here are two samples of what I would like to get as a result<br />
<img src="http://dl.dropbox.com/u/46656926/add_words.png" alt="http://dl.dropbox.com/u/46656926/add_words.png" /><br />
<img src="http://dl.dropbox.com/u/46656926/rules.png" alt="http://dl.dropbox.com/u/46656926/rules.png" /><br />
Tricky thing here for me is how to resize the background image, so that it looks nice with both short and long text.</p>
<p>Could you tell me, please, how can I get what want?</p>
<p>Thank you in advance!
</p></description>
		</item>
		<item>
			<title>Jamorn on "Sortable and Droppable Menu &amp; Menu Items"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3009#post-18600</link>
			<pubDate>Sun, 15 Nov 2009 12:42:48 +0000</pubDate>
			<dc:creator>Jamorn</dc:creator>
			<guid isPermaLink="false">18600@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey guys, I'm currently toying with an idea of creating a class to handle a sortable menu something akin to the Mac OS X doc. This feature would make my game extremely user-friendly and add to the experience tremendously but right now I'm wondering if the current cocos classes can be extended to perform this function.</p>
<p>I am thinking of using the Menu and MenuItemAtlasSprite classes for this but not too sure if it'll be a problem later on. Anybody have any suggestions? In the mean time I'll go ahead and start writing it out and will probably share the finished code once it's done so other people who need this class can make use of it.
</p></description>
		</item>
		<item>
			<title>svenito on "MenuItem with image and text"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2784#post-17274</link>
			<pubDate>Tue, 03 Nov 2009 14:37:15 +0000</pubDate>
			<dc:creator>svenito</dc:creator>
			<guid isPermaLink="false">17274@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Sorry if I've missed something but from the header files I cannot see that it's possible to create a MenuItem with a background image and text. Am I correct?<br />
I ask because it would be great if I could have a reusable background image for all (or most) of my menu items with a font based text overlay rather than one for each item with different text</p>
<p>So is this possible or would I need to subclass  or other?</p>
<p>Thanks
</p></description>
		</item>
		<item>
			<title>mkrn on "Menu events"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1170#post-7067</link>
			<pubDate>Fri, 07 Aug 2009 01:33:25 +0000</pubDate>
			<dc:creator>mkrn</dc:creator>
			<guid isPermaLink="false">7067@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a serious problem here, and I think it's Menu class's fault.</p>
<p>In my game on it's layer (which is touch-enabled) I have a couple of menu layers (for restart when you've won or lost) </p>
<p>These menus are getting touches even if they're zOrdered to -1 or set visible = NO  or set to some far position, no matter what.  </p>
<p>So when you play you could accidentally hit that invisible menu and it would work.</p>
<p>I even went to menu.m code and tried to set   if(self.visible) on all the events.<br />
I think the problem is with<br />
	[[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES];<br />
 In menu.m:176 </p>
<p>Please give some advice as to how to disable them for when they're invisible (i.e. game is in progress) </p>
<p>Cocos2d 0.8
</p></description>
		</item>
		<item>
			<title>stolen on "CCMenuItemSprite with animated sprites"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5813#post-34567</link>
			<pubDate>Mon, 19 Apr 2010 06:33:38 +0000</pubDate>
			<dc:creator>stolen</dc:creator>
			<guid isPermaLink="false">34567@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi all,</p>
<p>I have been playing with Cocos2d for a few days now and gone through as much source/examples/google as I can to try and find out how to have an animated sprite in my menu. I found that whenever an animated sprite was added to a menu via CCMenuItemSprite the animation stopped. The examples show you can animate the CCMenuItemSprite, but I couldn't find anything that showed separate animation for each of the three (normal, selected, disabled) sprites.</p>
<p>This lead me to dig around the source code and I found this is because the three sprites aren't added to the CCMenuItemSprite as children, only as attributes of the class so when the CCNode onEnter function gets called the sprites never tell CCActionManager to resume their actions, hence the paused animations.</p>
<p>Before I go ahead and implement some work around I wanted to know am I going about this the wrong way or is this actually a bug/missing feature?</p>
<p>Any help would be greatly appreciated.
</p></description>
		</item>
		<item>
			<title>jd on "How to repeat action while MenuItem button held down?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/66#post-278</link>
			<pubDate>Thu, 11 Jun 2009 02:36:52 +0000</pubDate>
			<dc:creator>jd</dc:creator>
			<guid isPermaLink="false">278@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a MenuItem button that I want to fire bullets while being held down.  Is this possible?  If not, how can I accomplish button hold down with ccTouchesBegan?  Any help is appreciated.  I looked around but could not find anything.
</p></description>
		</item>
		<item>
			<title>Billy Lavoie on "Menu question"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/496#post-2918</link>
			<pubDate>Mon, 06 Jul 2009 13:18:43 +0000</pubDate>
			<dc:creator>Billy Lavoie</dc:creator>
			<guid isPermaLink="false">2918@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a menu with 20 items (from 1 to 20) and each menu item is a "button", all 20 have the same selector now my problem is that I don't know how to figure out which button was pressed using the sender variable. I tried to access the variable "selectedIndex" (which seems to hold the value I want) but I can't seem to be able to. </p>
<p>Anyone has a suggestion?
</p></description>
		</item>
		<item>
			<title>adamjacob on "MenuItem @Selector Help?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5573#post-33276</link>
			<pubDate>Thu, 08 Apr 2010 02:57:26 +0000</pubDate>
			<dc:creator>adamjacob</dc:creator>
			<guid isPermaLink="false">33276@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>I am a newbie at cocos2d and I am making a basic game to get the hang of how cocos2d works.  I ran into a problem with the MenuItems.  I need a way to know what menu item was pressed. </p>
<p>For Example:</p>
<p>	CCMenuItem *a = [CCMenuItemFont itemFromString:@"A"  target:self selector:@selector(check:)];<br />
        CCMenuItem *b = [CCMenuItemFont itemFromString:@"B" target:self selector:@selector(check:)];<br />
        CCMenuItem *c = [CCMenuItemFont itemFromString:@"C" target:self selector:@selector(check:)];</p>
<p>I need all the menu items to go through check: but I can't figure out a way to figure out what menu item was pressed.  I tried working with the sender for check: but it didn't seen to tell me exactly what button was pressed.</p>
<p>If someone could give me some pointers or maybe a better way of doing this I would greatly appreciate it.
</p></description>
		</item>
		<item>
			<title>rickms on "Suggestion:  Modification to CCMenuItem to allow class method callbacks."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/11447#post-64780</link>
			<pubDate>Sat, 27 Nov 2010 16:48:16 +0000</pubDate>
			<dc:creator>rickms</dc:creator>
			<guid isPermaLink="false">64780@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi All,</p>
<p>The question came up in #<a href='http://www.cocos2d-iphone.org/forum/tags/cocos2d-iphone'>cocos2d-iphone</a> about the ability to use a class method as a call back to a  CCMenuItem.  After some investigation is seems that this is not possible with the current CCMenuItem code, as CCMenuItem's initWithTargetSelector does:</p>
<pre><code>sig = [[rec class] instanceMethodSignatureForSelector:cb];</code></pre>
<p>After some simple testing it seems like modifying it to :</p>
<pre><code>sig = [rec methodSignatureForSelector:cb];</code></pre>
<p>Would allow for both class and instance methods to be used.</p>
<p>Thoughts?</p>
<p>Rick
</p></description>
		</item>
		<item>
			<title>smooth on "Custom MenuItems positions/rotations"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3456#post-21145</link>
			<pubDate>Wed, 16 Dec 2009 20:10:03 +0000</pubDate>
			<dc:creator>smooth</dc:creator>
			<guid isPermaLink="false">21145@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Is there any way to set custom positions and rotations/angles for MenuItems  in the menu?
</p></description>
		</item>
		<item>
			<title>eshirt on "Using CCMenuItemSprite with CCSpriteBatchNode"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/9729#post-55933</link>
			<pubDate>Mon, 20 Sep 2010 15:42:02 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">55933@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've just upgraded to 0.99.5b2 from 0.8.1 and I have a clean build with no warnings or errors.  However, when I compile, I get an error on my Main Menu Layer that reads "If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#<a href='http://www.cocos2d-iphone.org/forum/tags/draw'>draw</a> SHOULD NOT be called."</p>
<p>In my previous code, I was doing this:</p>
<pre><code>mgr = [AtlasSpriteManager spriteManagerWithFile:@&#34;mmAtlasSprite.png&#34;];
[self addChild:mgr z:2];

AtlasSprite *newGame = [AtlasSprite spriteWithRect:CGRectMake(1, 116, 128, 22) spriteManager:mgr];
// 14 sprites created this way

[mgr addChild:newGame];

MenuItemAtlasSprite *newGameBtn = [MenuItemAtlasSprite itemFromNormalSprite:newGame selectedSprite:newGameSel target:self  selector:@selector(newGame:)];

Menu *menu = [Menu menuWithItems:newGameBtn, nil];

[self addChild:menu z:2];</code></pre>
<p>And now I have this:<br />
<pre><code>mgr = [CCSpriteBatchNode batchNodeWithFile:@&#34;mmAtlasSprite.png&#34;];
[self addChild:mgr z:2];

CCSprite *newGame = [CCSprite spriteWithBatchNode:mgr rect:CGRectMake(1, 116, 128, 22)];
// 14 sprites created this way

[mgr addChild:newGame];

CCMenuItemSprite *newGameBtn = [CCMenuItemSprite itemFromNormalSprite:newGame  selectedSprite:newGameSel target:self selector:@selector(newGame:)];

CCMenu *menu = [CCMenu menuWithItems:newGameBtn, nil];

[self addChild:menu z:2];</code></pre>
<p>This is obviously not the way to do it anymore, but I don't understand the proper way to create MenuItems from what used to be called AtlasSprites.  I understand that what's happening is [draw] is getting called twice on the CCSprite, or rather, the exception is keeping it from calling it twice.  I just don't know how to get around it.</p>
<p>I found a little information on the forum on this thread <a href="http://www.cocos2d-iphone.org/forum/topic/4933" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/4933</a> but rather than modify the source, I'd like to learn how to do it properly.  </p>
<p>This thread <a href="http://www.cocos2d-iphone.org/forum/topic/8042#post-46846" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/8042#post-46846</a> seems to say it's not possible.  That's fine, but how should it be done?</p>
<p>Thanks for any help you can offer.
</p></description>
		</item>
		<item>
			<title>pabloruiz55 on "Passing an argument to a menuitem&#039;s selector"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5317#post-31806</link>
			<pubDate>Sat, 27 Mar 2010 21:05:19 +0000</pubDate>
			<dc:creator>pabloruiz55</dc:creator>
			<guid isPermaLink="false">31806@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Is it possible?<br />
I have a menu with 10 items, each item calls a function (should call the same function) with a different string.</p>
<p>so i end up having 10 different functions for example:</p>
<pre><code>CCMenuItemFont * m0 = [CCMenuItemFont itemFromString:@&#34;0&#34; target:self selector:@selector(inf0:)];
CCMenuItemFont * m1 = [CCMenuItemFont itemFromString:@&#34;1&#34; target:self selector:@selector(inf1:)];

-(void)inf1:(id)sender
{
[self callAFunc:@&#34;blaaaaa&#34;];
}

-(void)inf2:(id)sender
{
[self callAFunc:@&#34;blaaaaa2&#34;];
}</code></pre>
<p>is there a way i could set that up so i can just do:<br />
<pre><code>CCMenuItemFont * m0 = [CCMenuItemFont itemFromString:@&#34;0&#34; target:self selector:@selector(inf:???)???];
CCMenuItemFont * m1 = [CCMenuItemFont itemFromString:@&#34;0&#34; target:self selector:@selector(inf:???)???];

-(void)inf:(id)sender data:(NSString *)data
{
[self callAFunc:@&#34;data&#34;];
}</code></pre>
<p>thanks
</p></description>
		</item>
		<item>
			<title>Reonarudo on "CCMenuItem..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8444#post-48990</link>
			<pubDate>Wed, 04 Aug 2010 10:46:56 +0000</pubDate>
			<dc:creator>Reonarudo</dc:creator>
			<guid isPermaLink="false">48990@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
Is there a way of using BMF in menu items? Like CCMenuItemAtlasFont but CCMenuItemBMFont.<br />
Is it implemented or is it easy to implement?</p>
<p>Thank you,
</p></description>
		</item>
		<item>
			<title>kyle_katarn on "How to addChild a CCMenuItem to a CCMenu from any other function than init"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5856#post-34753</link>
			<pubDate>Tue, 20 Apr 2010 19:16:38 +0000</pubDate>
			<dc:creator>kyle_katarn</dc:creator>
			<guid isPermaLink="false">34753@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a Menu interface that inherits from CCLayer, with two functions: init (overriden from CCLayer) and CreateMenuItem (defined in Menu). When I create a CCMenuItem and add it as a child of CCMenu in the init function, everything works just right. But when I do the same (create a CCMenuItem and add it as a child of CCMenu) in the CreateMenuItem function, the item does not display on the screen. It only works if I call CreateMenuItem from within init, but not if I call it from anywhere else, so it appears that the only way of getting it to work is creating and adding the item within the init function. By the way, this is based on the MenuTest example that comes with Cocos.</p>
<p>This is my code:<br />
<pre><code>@interface Menu : CCLayer
{
	NSMutableDictionary *itemPool;
	CCMenu *menu;
}

- (void) CreateMenuItemWithName:(NSString*)name image:(NSString*)staticImage rollover:(NSString*)rolloverImage selector:(NSString*)function;

@end

@implementation Menu

- (id) init
{
	if ((self = [super init]))
	{
		windowSize = [[CCDirector sharedDirector] winSize];
		itemPool = [[NSMutableDictionary alloc] init];

		CCMenuItem *gift = [CCMenuItemImage itemFromNormalImage:@&#34;UI_button_done01_small_static.png&#34; selectedImage:@&#34;UI_button_done01_small_rollover.png&#34; target:self selector:@selector(giftCallback:)];
		[gift setAnchorPoint:ccp(1, 0)];
		gift.position = ccp(windowSize.width/2 - 55, -windowSize.height/2);

		menu = [CCMenu menuWithItems:nil];
		[menu addChild:gift z:1 tag:1]; ---&#62; Everything&#39;s fine, the item is displayed on the screen

		[self addChild:menu];
	}

	return self;
}

- (void) CreateMenuItemWithName:(NSString*)name image:(NSString*)staticImage rollover:(NSString*)rolloverImage selector:(NSString*)function
{
	CCMenuItem *item = [CCMenuItemImage itemFromNormalImage:staticImage selectedImage:rolloverImage target:self selector:NSSelectorFromString(function)];
	[item setAnchorPoint:ccp(0, 0)];
	item.position = ccp(windowSize.width/2 - 110, -windowSize.height/2);

	[itemPool setObject:item forKey:name];

	[menu addChild:item z:1 tag:1]; ---&#62; Although I added the child, it is not displayed on the screen
}</code></pre>
<p>Has anyone had this problem, or knows a way to fix it?</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>geykel on "Checkbox MenuItem"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5729#post-34211</link>
			<pubDate>Thu, 15 Apr 2010 19:21:39 +0000</pubDate>
			<dc:creator>geykel</dc:creator>
			<guid isPermaLink="false">34211@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>Need some help implementing a Checkbox MenuItem, I think the best way to go is somehow mixing a Label for the text and a Sprite for the box in a MenuItem.</p>
<p>Any ideas?, any of you guys have ever do this?</p>
<p>Thanks
</p></description>
		</item>
		<item>
			<title>sunshineDev on "How to perform MenuItem selector without clicking on it"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/5407#post-32349</link>
			<pubDate>Wed, 31 Mar 2010 20:06:47 +0000</pubDate>
			<dc:creator>sunshineDev</dc:creator>
			<guid isPermaLink="false">32349@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello everyone,</p>
<p>I was looking to find a way to execute a MenuItem selector through code instead of having to click on the item. Is there a way to go about this?</p>
<p>Thanks in advance.
</p></description>
		</item>
		<item>
			<title>jugsvn on "Problem with MenuItemSprite!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/832#post-4920</link>
			<pubDate>Wed, 22 Jul 2009 14:10:00 +0000</pubDate>
			<dc:creator>jugsvn</dc:creator>
			<guid isPermaLink="false">4920@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey Guys,</p>
<p>Could someone please tell me why this is not working ?<br />
<pre><code>Sprite *mySprite = [Sprite spriteWithFile:@&#34;button-plain1.png&#34;];
	Label *mySpriteLabel = [Label labelWithString:@&#34;Start Game&#34; fontName:@&#34;Zapfino&#34; fontSize:18]; //creates label for sprite
	[mySpriteLabel setRGB:255 :255 :255]; //sets color of label
	[mySprite addChild: mySpriteLabel z:1]; // adds label to sprite
	CGSize s = [mySpriteLabel contentSize];
	mySpriteLabel.position = cpv(s.width * 0.50, s.height * 0.50); // positions label on sprite (cpv is relative to 0,0 point on parent sprite) 

	MenuItemSprite *item1 = [MenuItemSprite itemFromNormalSprite: mySprite selectedSprite: mySprite  disabledSprite: mySprite target:self selector:@selector(startGame:)];

	Menu *menu = [Menu menuWithItems:item1, nil];
	[menu alignItemsVertically];
	[self addChild: menu z:2];
	menu.position = cpv(320/2,100);</code></pre>
<p>The problem is I see only the button and not the text in it. However if I add mySprite to the Layer, I can see both the button and text on it.</p>
<p>I really appreciate all your help.
</p></description>
		</item>
		<item>
			<title>sunshineDev on "Menu layer is not detecting touches"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4580#post-27258</link>
			<pubDate>Thu, 18 Feb 2010 23:10:20 +0000</pubDate>
			<dc:creator>sunshineDev</dc:creator>
			<guid isPermaLink="false">27258@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everyone!</p>
<p>I am trying to test menus this time and they don't seem to be working. Here is what I am doing: (Remember, this is just a test)</p>
<pre><code>MenuItem *item1 = [MenuItemImage itemFromNormalImage:@&#34;Skull.png&#34; selectedImage:@&#34;Skull.png&#34; target:self selector:@selector(menuCallback1:)];
MenuItem *item2 = [MenuItemImage itemFromNormalImage:@&#34;Skull.png&#34; selectedImage:@&#34;Skull.png&#34; target:self selector:@selector(menuCallback2:)];

Layer *layer = [Layer node];
layer.isTouchEnabled = YES;

Menu *menu = [Menu menuWithItems: item1, item2, nil];
[menu alignItemsHorizontallyWithPadding:10];

[layer addChild:menu];
[scene addChild:layer];</code></pre>
<p>My callbacks simply do the following:</p>
<pre><code>-(void) menuCallback1: (id) sender
{
	NSLog(@&#34;THIS IS CALLBACK 1&#34;);
}</code></pre>
<p>I can see the menu perfectly in my scene but when I press any of the items the callback is not called. Any ideas why this might be happening?</p>
<p>Thanks again!
</p></description>
		</item>
		<item>
			<title>kenny on "MenuItem not displaying correctly"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3515#post-21405</link>
			<pubDate>Mon, 21 Dec 2009 03:11:02 +0000</pubDate>
			<dc:creator>kenny</dc:creator>
			<guid isPermaLink="false">21405@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello!!</p>
<p>Using cocos2d 0.8.2</p>
<p>I have 3 Items (Play, Intro, Help buttons) and they are all in a sprite sheet.  I use AtlasSpriteManager for each.</p>
<p><code>//List of Buttons</code><br />
<code>Menu *menu = [Menu menuWithItems: playButtonItem, introButtonItem, helpButtonItem, nil];</code><br />
<code>[menu alignItemsVertically];</code></p>
<p><code>// IMPORTANT</code><br />
<code>// If you are going to use AtlasSprite as items, you should</code><br />
<code>// re-position the AtlasSpriteManager AFTER modifying the menu position</code><br />
<code>menu.position = ccp( (screenSize.width/2), (screenSize.height/2));</code><br />
<code>playButtonMgr.position = menu.position;</code><br />
<code>introButtonMgr.position = menu.position;</code><br />
<code>helpButtonItem.position = menu.position;</code></p>
<p>It works fine with 2 items.  When I add the 3rd item, it sits on top of the second item.  I thought it would line them up automatically??</p>
<p>Please let me know what I am missing??</p>
<p>Thanks Again,</p>
<p>Kenny
</p></description>
		</item>
		<item>
			<title>wcrtr on "MenuItem size (for touch events) and animation"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1212#post-7298</link>
			<pubDate>Sat, 08 Aug 2009 19:55:45 +0000</pubDate>
			<dc:creator>wcrtr</dc:creator>
			<guid isPermaLink="false">7298@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey,</p>
<p>Quick question -- I'm using a MenuItem that is made with a BitmapFontAtlas, and I'm wondering if there's an issue with the way the frame of the Menu Item is being created.  </p>
<p>Basically, I have to press at the very bottom few pixels of the menu item for it to register... Ideally, it would check the frame of the entire menu item based on the size of the texture contained within but this doesn't seem to be working right.  </p>
<p>Any suggestions in regards to this?</p>
<p>Basic code:</p>
<p><code><br />
score = [BitmapFontAtlas bitmapFontAtlasWithString:@"start" fntFile:@"myfont.fnt"];<br />
[score.texture setAliasTexParameters];<br />
[score setAnchorPoint:CGPointMake(1, 0)];<br />
</code>	</p>
<p>This doesn't have to do with the anchorPoint, right?</p>
<p>Also, while I'm at it -- is there a way to use a setColor or something on the highlight stage of the button rather than animating/scaling it?</p>
<p>thanks in advance,<br />
w
</p></description>
		</item>
		<item>
			<title>briwil on "How to get a MenuItem&#039;s image"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2622#post-16298</link>
			<pubDate>Fri, 23 Oct 2009 03:32:48 +0000</pubDate>
			<dc:creator>briwil</dc:creator>
			<guid isPermaLink="false">16298@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey,<br />
I have a menu with a couple menuItems, and what I'm trying to do is- when you click on one of the menuItem's, I want to put its normal image into a variable; I had this working in a non-cocos2d version of my app, where I just told it:<br />
mainDelegate.stamp = [sender titleForState:UIControlStateNormal];</p>
<p>I would think it would be the same thing, I just don't know what to write after- stamp = [sender...<br />
I tried [sender normalimage], [sender itemFromNormalImage]...</p>
<p>Is this possible? Any help would be greatly appreciated, this is driving me crazy.<br />
Cheers,<br />
Brian
</p></description>
		</item>
		<item>
			<title>TD on "MenuItemSprite: Scaling of child-nodes?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2595#post-16124</link>
			<pubDate>Wed, 21 Oct 2009 14:52:49 +0000</pubDate>
			<dc:creator>TD</dc:creator>
			<guid isPermaLink="false">16124@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>A MenuItemSprite has three instance variables:</p>
<p>CocosNode&#60;CocosNodeRGBA&#62; *normalImage_, *selectedImage_, *disabledImage_;</p>
<p>I only want to scale this buttonimages, without any labels or other child nodes in the item, but it doesn't work. I tried something like:</p>
<p>[self.normalImage setScaleX:scaleX];</p>
<p>Anyone has an idea? What do I wrong?
</p></description>
		</item>
		<item>
			<title>tutukun on "MenuItemImage selector&#039;s target"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2483#post-15546</link>
			<pubDate>Thu, 15 Oct 2009 18:02:09 +0000</pubDate>
			<dc:creator>tutukun</dc:creator>
			<guid isPermaLink="false">15546@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>ok, So here is the situation:<br />
I have a FoodMenu:Menu class since i need to overwrite the touch functions. </p>
<p>'@property(nonatomic, retain) Texture2D* selected;</p>
<p>-(id) init<br />
{<br />
	MenuItemImage* apple = [MenuItemImage itemFromNormalImage:@"food_healthy_apple.png" selectedImage:@"food_healthy_apple.png" target:self selector:@selector(giveapple:)];</p>
<p>	self = [[FoodMenu menuWithItems:apple, nil] retain];<br />
	[self alignItemsInColumns:[NSNumber numberWithUnsignedInt:3],[NSNumber numberWithUnsignedInt:3], nil];</p>
<p>	selected = nil;<br />
	worldItem = nil;<br />
	world = [World sharedWorld];</p>
<p>	return self;<br />
}</p>
<p>-(void) giveapple: (id)sender<br />
{<br />
	if(selected)<br />
		[selected release];<br />
	selected = nil;<br />
	selected = [[TextureMgr sharedTextureMgr] addImage:@"food_healthy_apple.png"];<br />
}</p>
<p>-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event<br />
{<br />
	if(self.visible == NO) return NO;<br />
	[super ccTouchBegan:touch withEvent:event];<br />
	if(!selectedItem)<br />
	{<br />
		self.visible = NO;<br />
		return NO;<br />
	}<br />
	//[selectedItem activateWithTarget:self];<br />
	[selectedItem activate];<br />
	return YES;<br />
}'</p>
<p>It seems instead of copy pointer, the invocation create an copy of the actual instance of the target. Ive test it by create a func call activeWithTarget in MenuItem</p>
<p>'-(void) activateWithTarget:(id)target<br />
{<br />
	if(isEnabled)<br />
        [invocation invokeWithTarget:target];<br />
}'</p>
<p>if I use the function invoke, variable selected will return to  nil after giveapple finished since all the change was in another instance.<br />
Things works fine with activateWithTarget.</p>
<p>Is this a bug? Can anyone clarify this for me?</p>
<p>Cheers
</p></description>
		</item>
		<item>
			<title>astropaul on "Menu button doesn&#039;t respond when close to screen edge"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2302#post-14380</link>
			<pubDate>Mon, 05 Oct 2009 22:28:04 +0000</pubDate>
			<dc:creator>astropaul</dc:creator>
			<guid isPermaLink="false">14380@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm using 0.8.1.<br />
Menu's work fine for me, except when placed near the screen edges.<br />
Then they become very difficult to trigger. A direct touch does not<br />
work. You have to like touch the edges, and it's very difficult to<br />
get it to trigger. I create the menu button like this:</p>
<p>MenuItem *btnNext = [MenuItemFont itemFromString:@"Play Next..." target:self selector:@selector(playNext:)];<br />
Menu *btnNextScene = [Menu menuWithItems:btnNext, nil];<br />
btnNextScene.position = ccp( 200, 30);<br />
btnNextScene.visible = NO;<br />
[self addChild:btnNextScene z:5 tag:NEXT_BUTTON];</p>
<p>If I position it at 160,240   it works perfectly.<br />
But if I position it near the bottom of the screen, it does not work.<br />
Help!
</p></description>
		</item>
		<item>
			<title>mryan on "Menus, MenuItem, and Touch Behavior"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1855#post-11572</link>
			<pubDate>Mon, 14 Sep 2009 04:41:01 +0000</pubDate>
			<dc:creator>mryan</dc:creator>
			<guid isPermaLink="false">11572@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>In this topic, for the purpose of clarity, the term "<strong>TouchBegan</strong>" will refer to the event caused by a user either touching a GUI element or depressing the mouse button over a GUI element. The term "<strong>TouchEnded</strong>" will likewise refer to the user ending the touch or releasing the mouse button.</p>
<p>In most OSs (Windows, OS X, iPhone OS), a button's <em>active</em> or <em>hover</em> state is triggered with <strong>TouchBegan</strong>, but the button isn't actually activated until it also receives <strong>TouchEnded</strong>.  Also, if the mouse or touch is moved off the button after <strong>TouchBegan</strong>, but before <strong>TouchEnded</strong>, the button's <em>hover</em> state is disabled, and the user can safely release the touch without activating either the button initially pressed or any other GUI element (TouchCancelled).  Prior to <strong>TouchEnded</strong>, dragging over any GUI element other than the one originally pressed will do nothing, and no <em>hover</em> state will be triggered.  Finally, the user can drag the touch back to the original button, which re-triggers <em>hover</em>, and when <strong>TouchEnded</strong> is received the button will be activated.</p>
<p>This behavior can be demonstrated in Windows GUI applications, in OS X (such as the System Preferences panel), and on the iPhone by pressing down on the dock icons.  On the iPhone, press down on Safari (or another dock icon), and quickly move back and forth between it and an adjacent icon.  The Safari <em>hover</em> will be disabled when the touch is dragged off it, and the adjacent icon hover event never triggers.  You can safely release the touch while over any other icon without activating it, or drag the touch back to the Safari icon and release to load Safari.</p>
<p>This is the behavior I would like to use in my cocos2d application, but the current Menu system with the various MenuItem classes don't behave this way.</p>
<p>The cocos2d-iphone <em>MenuTest</em> target can be used to demonstrate the current behavior.  When you press down on one button, and then drag over adjacent buttons, the <em>hover</em> state of each button you drag over is enabled.  When the touch is released, the button under the touch is activated, regardless of whether it was the button initially pressed.  I don't know if this behavior is a bug or by design, but I personally would like to see the MenuItems have the behavior described at the top of this post instead.</p>
<p>If this is considered a bug, I'll create a bug report.  If not, how should I go about correcting this?  I'm very new to cocos2d, Objective-C, and Xcode, but have some experience programming in other C-based languages (C++, C#).  I haven't looked at the cocos2d code yet to see how the current system is setup, but at the very least, I assume it would need to keep track of the menu item initially pressed.</p>
<p><em>EDIT: I'm using cocos2d 0.8.1</em>
</p></description>
		</item>
		<item>
			<title>eshirt on "Menu selection"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2180#post-13705</link>
			<pubDate>Tue, 29 Sep 2009 02:17:11 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">13705@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I can't seem to find a way to implement something I've been working on...  Is there a way to tell if a Menu already contains a MenuItem that is set to selected?  For example, I've got a Menu with 12 MenuItemImages.  I want to be able to click on one image, and it will be selected (switching to the "selected" image appropriately).</p>
<p>I've got that working fine, but now every button I tap gets selected and remains selected.  I'd like to be able to check to see if another item is selected, if so, deselect that one and select the most recent tap.  Here's an example of my code:</p>
<pre><code>- (void) init {

// normal layer setup stuff
MenuItemImage *image1 = [MenuItemImage itemFromNormalImage:@&#34;image1.png&#34;
													selectedImage:@&#34;image1_sel.png&#34;
														   target:self
														 selector:@selector(setSelectedImage:)];
MenuItemImage *image2 = [MenuItemImage itemFromNormalImage:@&#34;image2.png&#34;
													selectedImage:@&#34;image1_sel.png&#34;
														   target:self
														 selector:@selector(setSelectedImage:)];
// and so on, for a few more items
Menu *menu = [Menu menuWithItems: image1, image2, [and on and on], nil];

// menu position and alignment, then add child on top of all other layers
}

- (void) setSelectedImage: (id)sender {
[sender selected];
}</code></pre>
<p>Thanks in advance for any help you can offer!
</p></description>
		</item>
		<item>
			<title>rbrooky on "MenuItem color issue"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1836#post-11484</link>
			<pubDate>Sat, 12 Sep 2009 22:56:34 +0000</pubDate>
			<dc:creator>rbrooky</dc:creator>
			<guid isPermaLink="false">11484@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
I have a question regarding changing the color of a menu item after it is selected. This is my code:</p>
<p>in init:<br />
		MenuItem *glob = [MenuItemFont itemFromString:@"Global"<br />
												   target:self<br />
												 selector:@selector(global:)];<br />
		 Menu *menu = [Menu menuWithItems:loc, fr, glob, mn, mail, nil];<br />
		globalItem = [glob retain];</p>
<p>(I have left out some code that sets up the other menu items)</p>
<p>Then in the "global" method:<br />
	[globalItem setRGB:200 :0 :0];</p>
<p>This changed the color of the menu item global to red. Works fine but it gives a warning. I do this quite a few times and so I have a whole list of warnings that I would like to get rid of. Warning is:<br />
"MenuItem may not respond to setRGB" even though it does</p>
<p>Anyone any suggestions how to avoid the warnings?<br />
Thanks!
</p></description>
		</item>
		<item>
			<title>zon7 on "Sprite + Label problem"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1599#post-10035</link>
			<pubDate>Sun, 30 Aug 2009 17:51:35 +0000</pubDate>
			<dc:creator>zon7</dc:creator>
			<guid isPermaLink="false">10035@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm trying to draw a card game. I have a texture with the four colors an I add the number to the card. The problem is that I want they linked together in a class (subclass of layer or something, i've tried everything) but as the texture is loaded in the main layer, the sprite is not drawn.</p>
<p>Right now I have this working</p>
<p>Sprite *sp= [SpriteObject spriteWithRect:CGRectMake(idx*img_w,idy*img_h,img_w,img_h) spriteManager:mgr];</p>
<p>sp.position=ccp(size.width/5+px*img_w*1.5,5*size.height/6-img_h*py);<br />
sp.scale=scale;<br />
sp.rotation=45-rand()%90;</p>
<p>Label *label = [Label labelWithString:[NSString stringWithFormat:@"%d",r_cards[x][1]] fontName:@"Marker Felt" fontSize:60];<br />
[label setColor:ccc3(0,0,0)];<br />
label.position =  ccp(size.width/5+px*img_w*1.5,5*size.height/6-img_h*py);<br />
label.rotation=sp.rotation;<br />
[self addChild: label];</p>
<p>[mgr addChild:sp];</p>
<p>But if I outsource this to another class, the label is drawn but not the sprite. Also making [sp addChild:label] won't work.</p>
<p>Any workaround?<br />
Thanks
</p></description>
		</item>
		<item>
			<title>manucorporat on "MenuItemBitmapFontAtlas"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/826#post-4887</link>
			<pubDate>Wed, 22 Jul 2009 09:27:10 +0000</pubDate>
			<dc:creator>manucorporat</dc:creator>
			<guid isPermaLink="false">4887@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>With this code you can create MenuItem BitMapFontAtlas.</p>
<p>MenuItem.h:</p>
<p>@interface MenuItemBitmapFontAtlas : MenuItemLabel<br />
{</p>
<p>}</p>
<p>+(id) itemFromString: (NSString*) value fntFile:(NSString*)fntFile;<br />
+(id) itemFromString: (NSString*) value fntFile:(NSString*)fntFile target:(id) rec selector:(SEL) cb;<br />
-(id) initFromString: (NSString*) value fntFile:(NSString*)fntFile target:(id) rec selector:(SEL) cb;</p>
<p>@end</p>
<p>MenuItem.m:</p>
<p>#pragma mark  -<br />
#pragma mark MenuItemBitmapFontAtlas</p>
<p>@implementation MenuItemBitmapFontAtlas</p>
<p>+(id) itemFromString: (NSString*) value fntFile:(NSString*)fntFile<br />
{<br />
	return [[[self alloc] initFromString:value fntFile:fntFile target:nil selector:nil] autorelease];<br />
}</p>
<p>+(id) itemFromString: (NSString*) value fntFile:(NSString*)fntFile target:(id) rec selector:(SEL) cb<br />
{<br />
	return [[[self alloc] initFromString:value fntFile:fntFile target:rec selector:cb] autorelease];<br />
}</p>
<p>-(id) initFromString: (NSString*) value fntFile:(NSString*)fntFile target:(id) rec selector:(SEL) cb<br />
{<br />
	NSAssert( [value length] != 0, @"value lenght must be greater than 0");</p>
<p>	BitmapFontAtlas *label = [[BitmapFontAtlas alloc] initWithString:value fntFile:fntFile];<br />
	[label autorelease];</p>
<p>	if((self=[super initWithLabel:label target:rec selector:cb]) ) {<br />
		// do something ?<br />
	}</p>
<p>	return self;<br />
}</p>
<p>-(void) dealloc<br />
{<br />
	[super dealloc];<br />
}<br />
@end
</p></description>
		</item>

	</channel>
</rss>

