<?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; Topic: Does CCMenuItem Work with CCSpriteSheet?</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/3874</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 02:09:16 +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/topic/3874" rel="self" type="application/rss+xml" />

		<item>
			<title>PhilM on "Does CCMenuItem Work with CCSpriteSheet?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3874#post-25989</link>
			<pubDate>Mon, 08 Feb 2010 18:43:58 +0000</pubDate>
			<dc:creator>PhilM</dc:creator>
			<guid isPermaLink="false">25989@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've just spent the last 10+ hours converting my main project from 0.8.2 to 0.99.0-rc, and seem to have everything working except box2d debug drawing, and a minor physics collision issue.</p>
<p>A large chunk of that time was spent re-factoring out the many, many MenuItemAtlasSprite's I had, which gave that error before swapping things about.</p>
<p>The release notes mention its removal, see the 'Removed MenuItemAtlasSprite' in 'Compatibility Issues' section:<br />
<a href="http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_0_rc" rel="nofollow">http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_0_rc</a></p>
<p>So instead of creating the menu items via a sprite sheet (menuManager in your case), you can use:<br />
[CCSprite spriteWithFile:rect:]<br />
which cuts out quite a few lines of code once done.</p>
<p>On the plus side, despite the time its taken to do, it seems worth the upgrade, especially to get access to all the cool new features...
</p></description>
		</item>
		<item>
			<title>fchan on "Does CCMenuItem Work with CCSpriteSheet?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3874#post-25983</link>
			<pubDate>Mon, 08 Feb 2010 17:26:37 +0000</pubDate>
			<dc:creator>fchan</dc:creator>
			<guid isPermaLink="false">25983@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>i am getting a similar problem as well
</p></description>
		</item>
		<item>
			<title>napierzaza on "Does CCMenuItem Work with CCSpriteSheet?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3874#post-23172</link>
			<pubDate>Wed, 13 Jan 2010 16:23:58 +0000</pubDate>
			<dc:creator>napierzaza</dc:creator>
			<guid isPermaLink="false">23172@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I am migrating from 0.8.2 to 0.9beta2.</p>
<p>I'm steadfastly working to have this new system work, but a scene which only contains a CCSprite and a CCSpriteSheet is crashing with "'If CCSprite is being rendered by CCSpriteSheet, CCSprite#<a href='http://www.cocos2d-iphone.org/forum/tags/draw'>draw</a> SHOULD NOT be called'"</p>
<p>Now, I'm not sure what's going wrong with this. I have another project with 0.9 (which I started from scratch) and it works okay. I'm just not using the CCMenuItem options (as below). It looks like possibly the CCMenuItem is trying to call "draw" on the CCSprite? I know that I'm not adding regular sprites to the spriteSheet and vice versa, so I'm not sure why else it would be slagging as I'm not calling draw anywhere directly (as I should!).</p>
<p>Code is below, I thought of cleaning it up for readers, but I felt I might exclude some information.</p>
<p><code><br />
CODE:<br />
	menuManager = [CCSpriteSheet spriteSheetWithFile:@"menu.png" capacity:12];<br />
	[self addChild:menuManager];</p>
<p>	//START<br />
	CCSprite *item;<br />
	CCSprite *itemSel;<br />
	CCSprite *itemDis;</p>
<p>	int block = 160;<br />
	int key = 0;<br />
	int opacity = 64;</p>
<p>	//Play Button<br />
	item = [menuManager createSpriteWithRect:CGRectMake(0,key,320,32)];<br />
	itemSel = [menuManager createSpriteWithRect:CGRectMake(0,key+block,320,32)];<br />
	itemDis = [menuManager createSpriteWithRect:CGRectMake(0,key,320,32)];<br />
	itemDis.opacity = opacity;</p>
<p>	[menuManager addChild:item];<br />
	[menuManager addChild:itemSel];<br />
	[menuManager addChild:itemDis];</p>
<p>	CCMenuItemSprite *buttonPlay = [CCMenuItemSprite itemFromNormalSprite:item selectedSprite:itemSel disabledSprite:itemDis target:self selector:@selector(buttonPlayGame:)];</p>
<p>~ ... Declaring even more CCMenuItems ... ~</p>
<p>	//Create Menu Itself</p>
<p>	CCMenu *menu = [CCMenu menuWithItems:buttonResume,buttonPlay,buttonHighScores,buttonInstructions,buttonFiller,buttonAlsoBy,nil];<br />
	[menu alignItemsVertically];<br />
	menu.position = CGPointMake(menu.position.x, menu.position.y-115);</p>
<p>	// IMPORTANT<br />
	// If you are going to use AtlasSprite as items, you should<br />
	// re-position the AtlasSpriteManager AFTER modifying the menu position<br />
	menuManager.position = menu.position;</p>
<p>	[self addChild: menu];<br />
</code>
</p></description>
		</item>

	</channel>
</rss>

