<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<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: MenuItemImage selector&#039;s target</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/2483</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Wed, 08 Sep 2010 12:51:24 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</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/2483" rel="self" type="application/rss+xml" />

		<item>
			<title>tutukun on "MenuItemImage selector&#039;s target"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2483#post-15613</link>
			<pubDate>Fri, 16 Oct 2009 08:45:36 +0000</pubDate>
			<dc:creator>tutukun</dc:creator>
			<guid isPermaLink="false">15613@http://www.cocos2d-iphone.org/forum/</guid>
			<description>&#60;p&#62;so anyone has any idea?
&#60;/p&#62;</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>&#60;p&#62;ok, So here is the situation:&#60;br /&#62;
I have a FoodMenu:Menu class since i need to overwrite the touch functions. &#60;/p&#62;
&#60;p&#62;'@property(nonatomic, retain) Texture2D* selected;&#60;/p&#62;
&#60;p&#62;-(id) init&#60;br /&#62;
{&#60;br /&#62;
	MenuItemImage* apple = [MenuItemImage itemFromNormalImage:@&#34;food_healthy_apple.png&#34; selectedImage:@&#34;food_healthy_apple.png&#34; target:self selector:@selector(giveapple:)];&#60;/p&#62;
&#60;p&#62;	self = [[FoodMenu menuWithItems:apple, nil] retain];&#60;br /&#62;
	[self alignItemsInColumns:[NSNumber numberWithUnsignedInt:3],[NSNumber numberWithUnsignedInt:3], nil];&#60;/p&#62;
&#60;p&#62;	selected = nil;&#60;br /&#62;
	worldItem = nil;&#60;br /&#62;
	world = [World sharedWorld];&#60;/p&#62;
&#60;p&#62;	return self;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;-(void) giveapple: (id)sender&#60;br /&#62;
{&#60;br /&#62;
	if(selected)&#60;br /&#62;
		[selected release];&#60;br /&#62;
	selected = nil;&#60;br /&#62;
	selected = [[TextureMgr sharedTextureMgr] addImage:@&#34;food_healthy_apple.png&#34;];&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event&#60;br /&#62;
{&#60;br /&#62;
	if(self.visible == NO) return NO;&#60;br /&#62;
	[super ccTouchBegan:touch withEvent:event];&#60;br /&#62;
	if(!selectedItem)&#60;br /&#62;
	{&#60;br /&#62;
		self.visible = NO;&#60;br /&#62;
		return NO;&#60;br /&#62;
	}&#60;br /&#62;
	//[selectedItem activateWithTarget:self];&#60;br /&#62;
	[selectedItem activate];&#60;br /&#62;
	return YES;&#60;br /&#62;
}'&#60;/p&#62;
&#60;p&#62;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&#60;/p&#62;
&#60;p&#62;'-(void) activateWithTarget:(id)target&#60;br /&#62;
{&#60;br /&#62;
	if(isEnabled)&#60;br /&#62;
        [invocation invokeWithTarget:target];&#60;br /&#62;
}'&#60;/p&#62;
&#60;p&#62;if I use the function invoke, variable selected will return to  nil after giveapple finished since all the change was in another instance.&#60;br /&#62;
Things works fine with activateWithTarget.&#60;/p&#62;
&#60;p&#62;Is this a bug? Can anyone clarify this for me?&#60;/p&#62;
&#60;p&#62;Cheers
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
