<?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: singleton - Recent Posts</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/singleton</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 03:25:14 +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/singleton" rel="self" type="application/rss+xml" />

		<item>
			<title>Karl on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143512</link>
			<pubDate>Thu, 09 Feb 2012 19:55:28 +0000</pubDate>
			<dc:creator>Karl</dc:creator>
			<guid isPermaLink="false">143512@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>When you find that classes require two-way communication, it can commonly be a sign of bad OO design, as birkemose said. However, there are cases where it's completely warranted. In such a case, you have three choices:</p>
<p>1. Make both aware of each other using the @class forward declaration, as mentioned earlier (this is usually the wrong approach).<br />
2. Use the delegate pattern, which is a commonly used pattern in UIKit (UIApplicationDelegate being used in EVERY iOS app).<br />
3. Register callbacks for the object that doesn't need to know about the other, except for notifications. This can be done with target/selector, blocks, or even monitoring NSNotifications or KVO (which is useful when multiple classes may be interested in events a class could generate).
</p></description>
		</item>
		<item>
			<title>Duckwit on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143502</link>
			<pubDate>Thu, 09 Feb 2012 19:40:13 +0000</pubDate>
			<dc:creator>Duckwit</dc:creator>
			<guid isPermaLink="false">143502@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/20192'>Birkemose</a> - Very wise advice, and I would love to take the time to implement it - but this here is just for a quick level-editor I made for my personal use only, so the code doesn't really need to work 'well' it just needs to work. (Which it does, and very smoothly + extremely fast as well).
</p></description>
		</item>
		<item>
			<title>Birkemose on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143475</link>
			<pubDate>Thu, 09 Feb 2012 17:49:02 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">143475@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>While forward declarations work, they are no good.<br />
It is a common problem that you "suddenly" needs to cross-include two classes. Imo it should always be fixed by rethinking your class lay-out, because it will in the end result in a stronger OO-hierachy.
</p></description>
		</item>
		<item>
			<title>Duckwit on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143470</link>
			<pubDate>Thu, 09 Feb 2012 17:20:08 +0000</pubDate>
			<dc:creator>Duckwit</dc:creator>
			<guid isPermaLink="false">143470@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks @Martin and @<a href='http://www.cocos2d-iphone.org/forum/profile/31966'>frilla</a> - I implemented this just after @Martin posted and it is working beautifully. :)
</p></description>
		</item>
		<item>
			<title>frilla on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143469</link>
			<pubDate>Thu, 09 Feb 2012 17:07:16 +0000</pubDate>
			<dc:creator>frilla</dc:creator>
			<guid isPermaLink="false">143469@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>As @Martin stated, you can use a forward declaration @class classNameHere on your header files so tell the compiler that you'll be refering to classes with this name in the header file but you won't be able to use them in the header file (for example call one of their methods).</p>
<p>In the implementation file, you'll have to import the header files in order to actually use the objects.</p>
<p>classA.h:<br />
<pre><code>@class classB;

classB *_pointerToClassB;</code></pre>
<p>classB.h:<br />
<pre><code>@class classA

classA *_pointerToClassA;</code></pre>
<p>classA.m:<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;classB.h&#34;

//you can now use classB</code></pre>
<p>classB.m:<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;classA.h
//you can now use classA</code></pre></description>
		</item>
		<item>
			<title>Martin on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143468</link>
			<pubDate>Thu, 09 Feb 2012 16:58:17 +0000</pubDate>
			<dc:creator>Martin</dc:creator>
			<guid isPermaLink="false">143468@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I don't know whats the most proper solution, but you could use a protocol that one object conforms to, to define the methods the other object will use. Then both objects will import the file containing the protocol definition(s).<br />
And/Or you could import the header file of the other object only in the implementation file of your object. Afaik importing in the implementation does not generate cyclic dependencies.<br />
If your singleton stores a reference to the object you could use @class to "promise" the definition of the class will follow "later" (importing its header in the .m file). If I remember correctly that's how I usually do it.</p>
<p>p.s.: aaaand read this :)<br />
<a href="http://stackoverflow.com/questions/322597/class-vs-import" rel="nofollow">http://stackoverflow.com/questions/322597/class-vs-import</a>
</p></description>
		</item>
		<item>
			<title>Duckwit on "[?]Class A imports B, B needs to import A too..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29119#post-143466</link>
			<pubDate>Thu, 09 Feb 2012 16:50:53 +0000</pubDate>
			<dc:creator>Duckwit</dc:creator>
			<guid isPermaLink="false">143466@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>This is one of those stupid technical problem that I should be able to solve by now, but being bogged down by work and struggling to find programming time I can't seem to figure this out. </p>
<p>Class A is a singleton, it receives input from the user interface using Interface Builder.<br />
Class B is a CCLayer subclass (HelloWorldLayer)</p>
<p>B needs to know about a to send it some data via a method.<br />
A needs to know about B to call some methods in it when it receives certain file data from the NSOpenPanel. </p>
<p>B #imports A<br />
But if A imports B there are problems - (circular importing)  </p>
<p>How should I properly reference each class?
</p></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-142459</link>
			<pubDate>Fri, 03 Feb 2012 06:53:37 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">142459@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/34101'>Scryb</a> thank you for your really thoughtful post. I have been going over it in mind, been a really busy week!!!</p>
<p>As far as your comment about making a bulletCache singleton goes, you know I have been considering it, but there have been some thingz I have been unsure about, like<br />
a) How do I create a BulletCache singleton...I imagine it's a bit more complicated than just declaring:<br />
BulletCache* bulletCache = [BulletCache sharedBulletCache];</p>
<p>b) even if I did create a bulletCache singleton, I want to ultimately create a flexible game program where the player's gun type (and respective bullet sprites) is retained by the game:</p>
<p>in other words, I want to make a shoot 'em up (yeehaw! :b) where the player can pick up guns/choose guns from a menu, and have the respective bullet sprites fire from the gun...</p>
<p>Not sure the singletons will give me that flexibility, I'd love it if you could clear that up for me. Thanks! (:</p>
<p>-------------------------------</p>
<p>As far as implementing the code suggestions so far, Player was already a property of LevelObject, and I made LevelObject a property of the player class. </p>
<p>I have been getting compile errors, including in the interface file of the LevelObject:</p>
<p><code>-(BulletCache*) bulletCache;</code> </p>
<p>I get 16 replicate compile errors saying: "Expected ')' before 'BulletCache'</p>
<p>In the LevelObject.m file, the code:</p>
<pre><code>-(BulletCache*) bulletCache
{
CCNode* node = [self addChild:bulletCache z:1 tag:kTagBulletCache];
NSAssert([node isKindOfClass:[BulletCache class]], @&#34;not a BulletCache&#34;);
return (BulletCache*) node;
}</code></pre>
<p>gives me an error stating:<br />
<code>bulletCache undeclared</code></p>
<p>In the player class the code in the 'fireBullet' method:</p>
<pre><code>LevelObject* levelObject - [LevelObject node];
BulletCache* bulletCache = [levelObject.player bulletCache];</code></pre>
<p>produces the code: `Request for member 'player' in something not a structure or union.'</p>
<p>Thanks for the help boys, I really appreciate it, I have been learning a ton, especially from you @<a href='http://www.cocos2d-iphone.org/forum/profile/34101'>Scryb</a> :D
</p></description>
		</item>
		<item>
			<title>Scryb on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141963</link>
			<pubDate>Tue, 31 Jan 2012 08:13:26 +0000</pubDate>
			<dc:creator>Scryb</dc:creator>
			<guid isPermaLink="false">141963@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>No that would work, and then you would call [levelObject bulletCache];</p>
<p>But if you have another class Player of which you add an instance as a child of levelObject, then getChildByTag wouldn't find the BulletCache object since that is a child of player, not levelObject.</p>
<p>What I think you should do is make bulletCache a property of Player, and then make the player a property of LevelObject. Then you can access it like this: [levelObject.player bulletCache]</p>
<p>---</p>
<p>Now as for your confusion about classes and objects, I recommend you reread Apples basic objective c docs. A class is a descriptor for creating objects and the class itself also exists as an object (otherwise you couldn't send messages such as [CCSprite spriteWithFile:@"img.png"]. But the class object doesn't hold any instance variables (they're called "instance" variables because they belong to instances of the class). Because you can create as many instances as you want of each class, each instance (object) holds its own instance variables. You could make several Player objects for instance, and each would have its own BulletCache child.</p>
<p>What you normally do if you want to have a class that is only gonna be a single object is to make a singleton. You can search the forum or google to find out more about that, but you should already be familiar with them since they are very common. Things like [CCDirector sharedDirector] and [[NSUserDefaults standardUserDefaults] are calls to singleton objects.
</p></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141944</link>
			<pubDate>Tue, 31 Jan 2012 06:29:46 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">141944@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/30412'>tim</a> BulletCache is a subclass of CCNode. As far as pointers go, I am trying to construct an accessor, which was started by declaring a property in the LevelObject interface:</p>
<p><code>@property BulletCache *bulletCache;</code></p>
<p>@<a href='http://www.cocos2d-iphone.org/forum/profile/34101'>Scryb</a>, that is interesting, but I am confused; self refers to the class object, not an object that is an instance of that class...I am not sure what you mean. Isn't that two ways of saying the same thing? </p>
<p>How is the class object NOT an object that is an instance of that class?</p>
<p>In regards to the concept of the LevelObject, that is an interesting idea, but there are several thoughts I have:</p>
<p>1) I'm 'initializing' the BulletCache in the init method of the Player, but I am also adding it as a child in there:<br />
<code>[self addChild:bulletCache z:1 tag:kTagBulletCache];</code></p>
<p>BUT my accessor method -(BulletCache*) bulletCache<br />
is in the LevelObject, which is the parent class of the Player class, and it is trying to get the tag:</p>
<p><code>CCNode *node = [self getChildByTag:kTagBulletCache];</code></p>
<p>So wouldn't that in itself create some confusion in the program?</p>
<p>My other big problem is that LevelObject does not have an -(id) init method with which to obviously slip in the BulletCache initializing statements, and because of this, I'm not sure how I could write a levelObject method with which the bulletCache could be accessed in the player class.</p>
<p>So ordinarily I'd write something like:</p>
<p><code>LevelObject* levelObject = [LevelObject node];</code></p>
<p>but that doesn't seem like it's an option, unless it's just because I'm new at this.</p>
<p>Anywayz, thanks guys for the help (o:
</p></description>
		</item>
		<item>
			<title>Scryb on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141935</link>
			<pubDate>Tue, 31 Jan 2012 04:57:19 +0000</pubDate>
			<dc:creator>Scryb</dc:creator>
			<guid isPermaLink="false">141935@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You're trying to call an instance method (bulletCache) on the class LevelObject, which obviously doesn't work. The class itself has no variables, so turning it into a class method wouldn't work ("self" in the Class refers to the class object, not an object that is an instance of that class)</p>
<p>I think what you're missing is actually initializing and storing a reference to an instance of LevelObject, which would usually be called levelObject.
</p></description>
		</item>
		<item>
			<title>timTheMystic on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141933</link>
			<pubDate>Tue, 31 Jan 2012 04:46:23 +0000</pubDate>
			<dc:creator>timTheMystic</dc:creator>
			<guid isPermaLink="false">141933@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>What is the parent class of bulletCache?   You may want to include a pointer to that parent in your LevelObject class.  Then make the  bulletCache  an instance method -</p>
<pre><code>- (BulletCache*) bulletCache {

    CCNode *node = [someParent getChildByTag:kTagBulletCache];
    NSAssert([node isKindOfClass:[BulletCache class]], @&#34;not a BulletCache&#34;);
    return (BulletCache*)node;
}</code></pre></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141911</link>
			<pubDate>Mon, 30 Jan 2012 22:08:12 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">141911@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hey Tim,  that is a very interesting point.  :o </p>
<p>However, merely adding a '+' in place of the '-' doesn't work, because there are other methods called within that method, such as "getChildByTag:" which is then not recognized by LevelObject</p>
<p>Additionally, I also get a warning telling me that I must synthesize the </p>
<p><code>@property (readonly, nonatomic) BUlletCache *bulletCache;</code></p>
<p>declaration, which I can do, but I don't think this is the proper direction. </p>
<p>I was able to successfully compile after adding a <code>@synthesize bulletCache;</code> declaration in the LevelObject.m, but tapping the attack button still produces a crash, because now the console complains that LevelObject won't respond to the 'getChildByTag' method.
</p></description>
		</item>
		<item>
			<title>timTheMystic on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141909</link>
			<pubDate>Mon, 30 Jan 2012 21:03:37 +0000</pubDate>
			<dc:creator>timTheMystic</dc:creator>
			<guid isPermaLink="false">141909@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>If you want the 'bulletCache' method to be a 'Class' method rather than an 'Instance' method, you'd need to define the method with a '+' in front of the method like this:</p>
<p>+(BulletCache*) bulletCache </p>
<p>this will allow for other Classes to access the method without having an instance of  the class.
</p></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141897</link>
			<pubDate>Mon, 30 Jan 2012 20:07:37 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">141897@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>ohno! well I tried to create accessors for the classes so the player unit would fire the bullet, but I keep running into the problem where methods just aren't recognized and causing crashes. ):</p>
<p>Here's my 'fireBullet' method:</p>
<pre><code>-(void) fireBullet
	{
		//as long as we&#039;re alive and not attacking
		if([self isAlive] &#38;&#38; ![self isAttacking])
		{
			//Always make noise, show life, and stop walking
			[self playSound:@&#34;attack&#34;];
			[self showLife];
			//[self stopWalking];
		}

		CCAction* action = [CCSequence actions:
			[CCAnimate actionWithAnimation:[profile getAnimation:
                                                     @&#34;attack&#34; index:currentDir]],
					             nil];
                //Make the BulletCache talk to the Player!!!
		BulletCache *bulletCache = [LevelObject bulletCache];

                //defining variables in firing bullet
		CGPoint shotPos = CGPointMake(self.position.x + [self contentSize].width
                                                                  * 0.5f, self.position.y);
		float spread = (CCRANDOM_0_1() - 0.5f) * 0.5f;
		CGPoint velocity = CGPointMake(4, spread);
		[bulletCache shootBulletFrom:shotPos velocity:velocity frameName:
                @&#34;bullet1big016.png&#34; isPlayerBullet:YES];

		action.tag = kActionAttack;
		[sprite runAction:action];					

	}</code></pre>
<p>I am able to compile, altho I get a warning that says 'LevelObject may not respond to '+bulletCache' and then of course the game crashes when I tap the "attack button" and I get this console error:<br />
<code>&#039;+[LevelObject bulletCache]: unrecognized selector sent to class 0xd6934&#039;</code></p>
<p>I have this method in the LevelObject class:</p>
<p>	-(BulletCache*) bulletCache<br />
{<br />
	CCNode *node = [self getChildByTag:kTagBulletCache];<br />
	NSAssert([node isKindOfClass:[BulletCache class]], @"not a BulletCache");<br />
	return (BulletCache*)node;<br />
}</p>
<p>this is soo frustrating guys, but I am determined to see this thru! 'preciate the help, it's been really encouraging (:
</p></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141714</link>
			<pubDate>Sun, 29 Jan 2012 07:07:37 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">141714@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Well I am tempted to go with LevelObject, because its the superclass of the Enemies, Player, and Items subclasses, which should mean (I am new to this lol) those classes should be able to inherit that accessor, but maybe I am wrong...</p>
<p>arrgh so tempting, I have to find out! (;
</p></description>
		</item>
		<item>
			<title>mijator on "HUD Layer Display and Controls"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28690#post-141649</link>
			<pubDate>Sat, 28 Jan 2012 17:56:51 +0000</pubDate>
			<dc:creator>mijator</dc:creator>
			<guid isPermaLink="false">141649@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I ended up using a singleton (GameManager) and created a global boolean there that responds when the button is touched. </p>
<p>Seems to be working well.  </p>
<p>For others who may have the same issue the steps are: </p>
<p>1. Create a new Objective C .h + .m file called GameManager.m<br />
2. Create your boolean in the .h file, including @property, along with the code to create the GameManager singleton (look it up) and a -(void) to set the Boolean (you don't have to actually write the method because it will be created when you synthesize the boolean).<br />
3. Use something like [[gameManager sharedGameManager] setMyBoolean:TRUE]] and if statements to use it in other files.
</p></description>
		</item>
		<item>
			<title>Tone on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141632</link>
			<pubDate>Sat, 28 Jan 2012 13:28:50 +0000</pubDate>
			<dc:creator>Tone</dc:creator>
			<guid isPermaLink="false">141632@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I would go by responsibility. Which class would be responsible for something like this.
</p></description>
		</item>
		<item>
			<title>tiffanyPea on "confuusing method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28735#post-141618</link>
			<pubDate>Sat, 28 Jan 2012 07:32:05 +0000</pubDate>
			<dc:creator>tiffanyPea</dc:creator>
			<guid isPermaLink="false">141618@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hai guys, haven't talked in a while, been suuuper busy.</p>
<p>Anywayz, I've been trying to write an accessor for my BulletCache class, but I've been trying to figure out where to put it in this game kit I've been playing with &#62;&#60;<br />
The game class files include a GameScene, a GameLayer, and a LevelObject class. </p>
<p>Here's the intended accessor:<br />
<pre><code>-(BulletCache*) bulletCache
{
	CCNode *node = [self getChildByTag:kTagBulletCache];
	NSAssert([node isKindOfClass:[BulletCache class]], @”not a 	BulletCache”);
	return (BulletCache*)node;
}</code></pre>
<p>I am tempted to put the BulletCache accessor in the GameScene, because I have seen conventional small game code put it there before. On the other hand, a small part of me wants to put it in the LevelObject, because this is the superclass of the Characters, Players, Enemies, and Items classes.
</p></description>
		</item>
		<item>
			<title>mijator on "HUD Layer Display and Controls"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28690#post-141396</link>
			<pubDate>Thu, 26 Jan 2012 18:12:39 +0000</pubDate>
			<dc:creator>mijator</dc:creator>
			<guid isPermaLink="false">141396@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've been trying to combine the code from 2 tutorials by Ray Wenderlich (Toggle Buttons and HUD Layer). It's sort of working, but not exactly as I want it to...</p>
<p>I want the HUD Layer to control a couple of boolean control buttons; e.g. similar to muting/turn-on background music, change mode of the active layer from A to B (i.e, if A Mode -&#62; doThis, if B Mode -&#62;doThat), turn special effects display on in the Hud Layer, etc.</p>
<p>I used (id)initWithHUD:(CCLayer *)hud; in the HelloWorldLayer as explained in the tutorial and a Toggle Button (explained in a separate tutorial).  Then I added a CCMenuItemToggle statement (in the HelloWorldLayer) that calls a method located in the HUD layer like so:</p>
<p>CCMenuItemToggle *toggleItem = [CCMenuItemToggle itemWithTarget:_hud<br />
           selector:@selector(plusMinusButtonTapped:) items:_plusItem, _minusItem, nil];</p>
<p>This works (i.e. the button appears in the HUD layer and switches from - to + when touched.  However, the method (plusMinusButtonTapped - located in the HUD Layer implementation file) only works the way it does in the tutorial if I don't use a HUD layer.  By using CCLog, I have determined that the method is called, i.e.</p>
<p>//in the HUD implementation file</p>
<p>- (void)plusMinusButtonTapped:(id)sender {  </p>
<p>    CCLOG(@"Info Mode Particle System17 Is Active."); //this message appears when init<br />
    CCMenuItemToggle *toggleItem = (CCMenuItemToggle *)sender;<br />
    CCLOG(@"toggleItem is %@ OR %@ ???",_plusItem, _minusItem); //this message appears when the button is touched</p>
<p>//the problem is that the CCLog says "toggleItem is (null) OR (null) ???" which means it doesn't have _plusItem or _minusItem (i.e. not sent when button is touched)...why does it work at all then???</p>
<p>//hence the following never gets called</p>
<p>    if (toggleItem.selectedItem == _plusItem) {</p>
<p>//set the Bool statement here, etc.</p>
<p>}</p>
<p>Please help!
</p></description>
		</item>
		<item>
			<title>Gray Olson on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140423</link>
			<pubDate>Fri, 20 Jan 2012 15:28:43 +0000</pubDate>
			<dc:creator>Gray Olson</dc:creator>
			<guid isPermaLink="false">140423@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Glad to see you're excited and learning already :) One last thing... have fun!</p>
<p>Gray
</p></description>
		</item>
		<item>
			<title>virag0 on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140350</link>
			<pubDate>Fri, 20 Jan 2012 07:30:40 +0000</pubDate>
			<dc:creator>virag0</dc:creator>
			<guid isPermaLink="false">140350@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks to everyone for replying!   Leo, that example is enough to get me started.<br />
I've done a couple of the excellent tutorials online and they really give the creator a huge<br />
head start.   Now I can work on my game logic and think about how to design the classes<br />
I want and how to present them.   The singleton concept is a good one.   I am a big fan<br />
of event driven programming and singletons are a good way to share variables,<br />
But I have also read it is not a good idea to dump everything into them, too!</p>
<p>I visited Bob's site too - so many great resources out there......  I have given myself<br />
a year to produce something worthwhile..... ......how can I go wrong?!   ;)</p>
<p>rachel
</p></description>
		</item>
		<item>
			<title>gametreesnet on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140157</link>
			<pubDate>Thu, 19 Jan 2012 05:12:16 +0000</pubDate>
			<dc:creator>gametreesnet</dc:creator>
			<guid isPermaLink="false">140157@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Welcome to Cocos2d!!!</p>
<p><a href="http://bobueland.com/cocos2d/" rel="nofollow">http://bobueland.com/cocos2d/</a> is a good place to start, too.<br />
Good luck!
</p></description>
		</item>
		<item>
			<title>Gray Olson on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140156</link>
			<pubDate>Thu, 19 Jan 2012 04:26:32 +0000</pubDate>
			<dc:creator>Gray Olson</dc:creator>
			<guid isPermaLink="false">140156@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>A good way to handle turn-based things would be to create a singleton class that you can pass data to, and it'll output data back. I'm not too familiar with turn-based game logic, but I think you need to just write out your own logic (part of creating any game) that is customized to your situation, not sure what else to tell you. Also, seems like many people jump on buying books before just looking around on the forum or the internet... I got to where I am now without buying anything(!). It just takes searching on google and reading articles... a great website to start out with is Ray Wenderlich's site, he's got a ton of great stuff to get you started. After that, search up on the forums and google, they're your FRIEND, and I recommend you do several simpler "test" games to get familiar with cocos before you delve into your serious project, it'll be much less frustrating and more productive that way.</p>
<p>Welcome to the community!</p>
<p>Gray
</p></description>
		</item>
		<item>
			<title>riousdelie on "Restart Level with Box2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19159#post-140154</link>
			<pubDate>Thu, 19 Jan 2012 04:12:14 +0000</pubDate>
			<dc:creator>riousdelie</dc:creator>
			<guid isPermaLink="false">140154@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi All,</p>
<p>sorry for bumping into old thread, but i found something interesting in this issue. This is not only a matter of restarting and reloading Box2D object.</p>
<p>I found that this problem occured eventhough objects are not reloaded and simply put the old scene back to be shown.</p>
<p>I made a new thread here: <a href="http://www.cocos2d-iphone.org/forum/topic/28474" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/28474</a></p>
<p>Hope we can find a new approach on this.</p>
<p>Thank you.
</p></description>
		</item>
		<item>
			<title>riousdelie on "Singleton Box2D Scene"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28474#post-140153</link>
			<pubDate>Thu, 19 Jan 2012 04:09:21 +0000</pubDate>
			<dc:creator>riousdelie</dc:creator>
			<guid isPermaLink="false">140153@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>related thread: <a href="http://www.cocos2d-iphone.org/forum/topic/19159" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/19159</a> (Restart Level with Box2d)</p>
<p>Hi All cocos2d-iphone Amazing Community Members,</p>
<p>I am trying to use a singleton pattern while designing my game. But encountering an issue when replace scene back to instantiated scene. The Box2D simulation is not working anymore.</p>
<p>Attached project source sample is here: <a href="http://siriusdely.com/dl/SingletonBox2D.zip" rel="nofollow">http://siriusdely.com/dl/SingletonBox2D.zip</a></p>
<p>Any help is appreciated. Thank you All.
</p></description>
		</item>
		<item>
			<title>Leo on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140146</link>
			<pubDate>Thu, 19 Jan 2012 02:24:43 +0000</pubDate>
			<dc:creator>Leo</dc:creator>
			<guid isPermaLink="false">140146@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Welcome! Hope you enjoy your stay and good luck in your cocos2d studies. </p>
<p>As basic as it gets.</p>
<pre><code>// on &#34;init&#34; you need to initialize your instance
-(id) init
{
	// always call &#34;super&#34; init
	// Apple recommends to re-assign &#34;self&#34; with the &#34;super&#34; return value
	if( (self=[super init])) {

        //begin the game
        [self beginAITurn];
	}
	return self;
}</code></pre>
<p>Player's stuff<br />
<pre><code>-(void)beginplayerTurn
{
    // clear screen
    [self removeAllChildrenWithCleanup:YES];

    // create and initialize a Label
    CCLabelTTF *label = [CCLabelTTF labelWithString:@&#34;It&#039;s your turn.&#34; fontName:@&#34;Marker Felt&#34; fontSize:24];
    // ask director the the window size
    CGSize size = [[CCDirector sharedDirector] winSize];
    // position the label on the center of the screen
    label.position =  ccp( size.width /2 , size.height/2 );
    // add the label as a child to this Layer
    [self addChild: label];

    //Add a menu to end your turn.
    // create and initialize a Label
    CCMenuItemLabel* endTurnMenuItem = [CCMenuItemLabel
                                        itemWithLabel:[CCLabelTTF labelWithString:@&#34;Tap here to end turn.&#34;
                                                                         fontName:@&#34;Marker Felt&#34;
                                                                         fontSize:30]
                                        target:self
                                        selector:@selector(endPlayerTurn)];
    endTurnMenuItem.color = ccYELLOW;

    CCMenu* endTurnMenu = [CCMenu menuWithItems:endTurnMenuItem, nil];
      // position the menu on the center of the screen
    endTurnMenu.position =  ccp( size.width /2 , size.height/2-50 );
    // add the label as a child to this Layer
    [self addChild: endTurnMenu];

}
-(void)endPlayerTurn
{
    //You&#039;d probably want to clean up  here.
    //Empty your variables, reset label positions, whatever. Then start the AI&#039;s turn.
    [self beginAITurn];
}</code></pre>
<p>Computer's  Stuff<br />
<pre><code>-(void)beginAITurn
{
    // clear screen
    [self removeAllChildrenWithCleanup:YES];

    //Put your AI logic here. For now, we&#039;ll just put a label and count to 3 then switch turns.

    // create and initialize a Label
    CCLabelTTF *label = [CCLabelTTF labelWithString:@&#34;It&#039;s the Computer&#039;s turn. Wait 3 Seconds.&#34; fontName:@&#34;Marker Felt&#34; fontSize:24];
    // ask director the the window size
    CGSize size = [[CCDirector sharedDirector] winSize];
    // position the label on the center of the screen
    label.position =  ccp( size.width /2 , size.height/2 );
    // add the label as a child to this Layer
    [self addChild: label];

    CCSequence* yourSequence = [CCSequence actions:
                                [CCDelayTime actionWithDuration:3.0f], //wait 3 seconds
                                [CCCallFunc actionWithTarget:self selector:@selector(endAITurn)] //end turn.
                                , nil];
    [self runAction:yourSequence];
}

-(void)endAITurn
{
    //You&#039;d probably want to clean up  here.
    //Empty your variables, reset label positions, whatever. Then start the player&#039;s turn.
    [self beginplayerTurn];
}</code></pre></description>
		</item>
		<item>
			<title>virag0 on "Hello from new member"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28471#post-140138</link>
			<pubDate>Thu, 19 Jan 2012 01:05:00 +0000</pubDate>
			<dc:creator>virag0</dc:creator>
			<guid isPermaLink="false">140138@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
I just wanted to introduce myself.   My name is rachel and I am just stepping into ObjC/Cocos2d and iOS programming.   My background is as a Solaris admin at an Australian Uni.  I am getting pretty old now and was looking for something to stimulate my mind while I watch my job get dumbed down.   In any case, I have a bit of experience in C/C++/shell and Perl.   I am not a programmer by any means though.   I did once work on some missions that were written in C++ for a game called "Starfleet Command" - this is what piqued my interest in Cocos2D, as I made a lot of progress learning in that sandbox and see Cocos2D as another framework that gives the developer a lot of power without them getting too caught up in the details. </p>
<p>So, I bought Stephan Itterheim's first book and am trying to get the Nathan Burba one as well.</p>
<p>My focus initially was to develop a hex tile based turn based strategy game, but I am still<br />
finding the hex coordinate stuff a little too deep for me, so I am going back for a simpler<br />
structure. </p>
<p>What I am mainly interested at this stage though, is just getting some Turn Based logic<br />
going.   I understand GameKit has something to do with this, but I do not understand how<br />
to just create the basic "I go, U go" logic of a turn based game.   The kind of structure<br />
I am looking at is like "Tactical Warrior" where the player selects their team and then<br />
plays turn by turn.   I do not know if you need GK to just do that bit, or if I can use GK<br />
to provide the framework, or if I have to write my own!?</p>
<p>So, if there is anyone who can advise on a very simple (at this stage) turn based structure,<br />
with player vs computer (for now), I am interested in how this is managed in Cocos2d and<br />
event driven logic etc!  </p>
<p>That is enough from me for now.  I am catching up (lurking) on the forum etc.<br />
BTW, I got the iTiled QT version that has the hex tilemap support (like the Java one). </p>
<p>I found a thread in this forum somewhere that mentioned it, so I pulled it from the<br />
person's repo (thankyou!) and successfully compiled it up for PPC (G5) and used it to<br />
create a tilemap.  I can load all this into my game sandbox no problems, but mapping the<br />
pixels to a hex coordinate is not working - I tried the example someone listed but it<br />
still skews halfway off the map.   So, I am looking for answers to that one as well.</p>
<p>If anyone wants my PPC QT/hex itiled, I will make it available somehow, but it compiles<br />
fine against MacPorts so it is not that hard for you experts ;) </p>
<p>Also, my dev environment is schizophrenic.  At home, I have a G5 desktop that I use<br />
Screen sharing to build apps in Xcode on our Mac Mini Server.   At work I have the latest<br />
and greatest iMac 27" with Lion and I use that one to learn the tutorials on (so there is<br />
no constraint over IP ownership should it come to that!).  So that makes it "interesting"<br />
as well. </p>
<p>Finally, reading the forum on here, you all seem like really nice helpful people who<br />
are enthusiastic about this platform and I note lots of egalitarian behaviour unlike<br />
some other forums which seem to have tetchy BOFH's who would rather point people to a man page<br />
than provide a simple example - I hope I do not become like that or a whiny annoying type,<br />
either!  </p>
<p>rachel
</p></description>
		</item>
		<item>
			<title>whoop on "Restart Level with Box2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19159#post-139823</link>
			<pubDate>Tue, 17 Jan 2012 08:57:44 +0000</pubDate>
			<dc:creator>whoop</dc:creator>
			<guid isPermaLink="false">139823@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I cannot restart my scene. I am using cocos2d and box2d.<br />
I try to restart my game with this code:<br />
[[CCDirector sharedDirector] replaceScene:[game scene]];</p>
<p>After this the init launched and then my app freezed - it target to this line:<br />
inline b2World* b2Body::GetWorld()<br />
{<br />
	return m_world; &#60;-- Bad access<br />
}</p>
<p>I create my world @ init and delete it in dealloc!
</p></description>
		</item>
		<item>
			<title>prashn64 on "Having a problem with the schedule method."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19965#post-111461</link>
			<pubDate>Fri, 19 Aug 2011 16:09:30 +0000</pubDate>
			<dc:creator>prashn64</dc:creator>
			<guid isPermaLink="false">111461@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Found the problem. The reason it didn't work for me is that I didn't add the object to the scene layer.  Apparently if it's not part of a scene, it is automatically set to paused.  Since I don't want to add an audio manager to a scene that is meant for drawing objects, I decided to use the objective c scheduler functions, or are these just cocos functions? Either way, the problem is the paused variable.</p>
<p>To schedule:<br />
[[CCScheduler sharedScheduler] scheduleSelector:@selector(checkAudioFileEnded:) forTarget:self interval:0.0 paused:NO];</p>
<p>To unschedule<br />
[[CCScheduler sharedScheduler] unscheduleSelector:@selector(checkAudioFileEnded:) forTarget:self];
</p></description>
		</item>

	</channel>
</rss>

