<?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: scene - Recent Topics</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/scene</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:58:00 +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/scene/topics" rel="self" type="application/rss+xml" />

		<item>
			<title>tiggybouncer on "CCMenuItem Scene transfer help! And some other stuff..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28958#post-142729</link>
			<pubDate>Sun, 05 Feb 2012 09:48:29 +0000</pubDate>
			<dc:creator>tiggybouncer</dc:creator>
			<guid isPermaLink="false">142729@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi.<br />
For the past few months, on my menus I have been using a piece of code similar to this to go from one scene to another:<br />
<pre><code>-(void)backToMainMenu:(id)sender
{
	MainMenuScene *mms = [MainMenuScene node];
	[[CCDirector sharedDirector]replaceScene:mms];
}</code></pre>
<p>This has worked in many other places inside my app, but it doesn't work now. Can someone please explain this to me.</p>
<p>Here is some more code to help:<br />
<pre><code>CCMenuItemLabel * backToMainMenu = [CCMenuItemLabel itemWithLabel:backToMainMenuLabel target:self selector:@selector(backToMainMenu:)];</code></pre>
<p>I have tried putting 'selector' on the end instead of 'sender'.</p>
<p>Another thing, yesterday, I created more defined colours in the ccTypes file. These all work wonderfully, so now there is a wider choice of colours to use. I would like to upload it to Github, but I can't. Is there anyone who I can send it to so it can be uploaded (I would be most grateful if someone could).</p>
<p>Thanks.</p>
<p>EDIT : I tested my code on the 1.0.1 version :)
</p></description>
		</item>
		<item>
			<title>DifferentSparks on "Change scenes and flickering"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28944#post-142691</link>
			<pubDate>Sat, 04 Feb 2012 21:08:52 +0000</pubDate>
			<dc:creator>DifferentSparks</dc:creator>
			<guid isPermaLink="false">142691@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Well, i've 2 scenes, GameOverScene and GamePlayScene. Both of them, have some layers like children (bg,ui ecc).<br />
When my player dies, i just do </p>
<pre><code>[[CCDirector sharedDirector] replaceScene :
             [CCTransitionFade transitionWithDuration : 2.0f
                                                scene : [GameOverScene node]]];</code></pre>
<p>and when the user touches the GameOverLayer</p>
<pre><code>[[CCDirector sharedDirector] replaceScene :
     [CCTransitionFade transitionWithDuration : 1.5f
                                        scene : [GamePlayScene node]]];</code></pre>
<p>Everything is ok, but sometimes, when i come back to the GamePlayScene, all my sprites(with box2d body) are flickering. this happens often if i have some music on the iPhone.</p>
<p>Should i do something for release the old scenes? Can be this the problem?</p>
<p>Currently i have all my GameObjects(CCSprite+Box2d body) in CCMutableArrays , so in the GamePlayerLayer's(GamePlayScene's child) dealloc method i just do</p>
<pre><code>[gameObjectArray release];</code></pre>
<p>Thanks
</p></description>
		</item>
		<item>
			<title>Seerex on "[SOLVED] Only display 1 of 2 layers on scene?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28936#post-142629</link>
			<pubDate>Sat, 04 Feb 2012 07:40:46 +0000</pubDate>
			<dc:creator>Seerex</dc:creator>
			<guid isPermaLink="false">142629@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>[ANSWER]</p>
<p>Oh well, i actually send the shared directer runWithScene: and passed in a layer, not a scene. To my surprise, this actually worked? So, the sharedDirector can't tell the difference between a scene or layer i guess? </p>
<p>Hi all,</p>
<p>I'm reading through a book on cocos2d, and the second chapter puzzles me. I created 2 layers, one containing a sprite as a character, the other a sprite as background. I then create a game scene that adds the 2 layers as childs in the init method. I then redirect the CCDirecter sharedDirector in the appDelegate.m to load in the gameScene. Now, i get displayed the layer showing the game scene, but not the background? any particular reason for this? Here are the code:</p>
<p>@implementation BackgroundLayer</p>
<p>-(id) init {<br />
    self = [super init];<br />
    if (self) {<br />
        CCSprite *backgroundImage;<br />
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {<br />
            // Indicate game is running on ipad<br />
            backgroundImage = [CCSprite spriteWithFile:@"background.png"];<br />
        } else {<br />
            backgroundImage = [CCSprite spriteWithFile:@"backgroundiPhone.png"];<br />
        }</p>
<p>        CGSize screenSize = [[CCDirector sharedDirector] winSize];<br />
        [backgroundImage setPosition:CGPointMake(screenSize.width/2, screenSize.height/2)];</p>
<p>        [self addChild:backgroundImage z:0 tag:0];<br />
    }</p>
<p>    return self;<br />
}</p>
<p>@implementation GameplayLayer</p>
<p>-(id) init {<br />
    self = [super init];<br />
    if (self) {<br />
        CGSize screenSize = [CCDirector sharedDirector].winSize;<br />
        // enable touches<br />
        self.isTouchEnabled = YES;<br />
        vikingSprite = [CCSprite spriteWithFile:@"sv_anim_1.png"];<br />
        [vikingSprite setPosition:CGPointMake(screenSize.width/2, screenSize.height*0.17f)];</p>
<p>        [self addChild:vikingSprite];</p>
<p>        if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {<br />
            // if NOT for the ipad, scale down ole<br />
            // in games, use this to load art sized for the device<br />
            [vikingSprite setScaleX:screenSize.width/1024.0f];<br />
            [vikingSprite setScaleY:screenSize.height/768.0f];<br />
        }<br />
    }</p>
<p>    return self;<br />
}</p>
<p>@implementation GameScene</p>
<p>-(id) init {<br />
    self = [super init];<br />
    if (self) {<br />
        // bacground layer<br />
        BackgroundLayer *backgroundLayer = [BackgroundLayer node];<br />
        [self addChild:backgroundLayer z:0];<br />
        // Gameplay layer<br />
        GameplayLayer *gameplayLayer = [GameplayLayer node];<br />
        [self addChild:gameplayLayer z:5];<br />
    }</p>
<p>    return self;<br />
}</p>
<p>Thanks on advance
</p></description>
		</item>
		<item>
			<title>callispo on "Cut the Rope style intro video"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28851#post-142149</link>
			<pubDate>Wed, 01 Feb 2012 14:55:45 +0000</pubDate>
			<dc:creator>callispo</dc:creator>
			<guid isPermaLink="false">142149@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I was wondering, the intro animation of Cut the Rope, in which theres a knock on the door, and Om Nom appears in a box, etc. How is this made? Is there any way I can embed videos in my game like that, because making a video like that, by using CCSprites and CCAnimation would consume a lot of memory.
</p></description>
		</item>
		<item>
			<title>aasulli1 on "help?image is bigger then the supported 2048x2048 error?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28385#post-139732</link>
			<pubDate>Mon, 16 Jan 2012 19:31:15 +0000</pubDate>
			<dc:creator>aasulli1</dc:creator>
			<guid isPermaLink="false">139732@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>i have a question im trying to load the tiled map to the cocos2d scene. do i have to load the png i used to make the tiled map or just the finished tiled map i saved? because my png is 4800x640 to fit all the artwork i needed to make the completed tileD map. because i got an error saying that 4800x640 is bigger then the supported 2048x2048. do i just need to load the tiled layers and not the artwork png. btw i dont have a seperate background the whole level is in tileD.
</p></description>
		</item>
		<item>
			<title>cocosbean on "Replace scene not replacing properly"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28173#post-138589</link>
			<pubDate>Sun, 08 Jan 2012 04:33:11 +0000</pubDate>
			<dc:creator>cocosbean</dc:creator>
			<guid isPermaLink="false">138589@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a main layer scene and a game layer scene. When I replace the game scene to go back to the main layer scene, I can still do the actions from the game layer scene for some reason even though it's displaying the main layer scene (can still shoot and sound effects also happen). Why is it not stopping everything from the game layer scene if I replace it with the main layer scene?
</p></description>
		</item>
		<item>
			<title>johntmcintosh on "Restart Level with Box2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19159#post-107371</link>
			<pubDate>Wed, 27 Jul 2011 15:48:30 +0000</pubDate>
			<dc:creator>johntmcintosh</dc:creator>
			<guid isPermaLink="false">107371@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi all,</p>
<p>I'm working on a cocos2d and box2d game and have been having some trouble implementing the ability to restart a level. First, here's my conceptual understanding of the correct approach:</p>
<p>I'm storing the data for my levels in XML files, so I have a single scene which loads which ever level is appropriate. The app delegate is in charge of replacing scenes whenever necessary. I have a menu scene which lets me choose which level to play. If I choose level 2, the app delegate replaces the scene with GameScene, which allows me to play that level. In GameScene I have the following methods (among others):</p>
<p>- init - which performs the first initialization<br />
- reset - which resets the values to an initial state and loads the data relevant to the current<br />
- dealloc - for the final deallocation</p>
<p>In my app delegate, I have a single instance of GameScene. Each time a level is selected, I call reset on that scene, that call replaceScene to make that the current scene.</p>
<p>Now, let's say I start on the menu to select a level. I press level 1, which calls nextLevel in my app delegate:<br />
<code><br />
- (void)nextLevel {<br />
    [_mainScene.layer reset];<br />
    [[CCDirector sharedDirector] replaceScene:_mainScene];<br />
}<br />
</code></p>
<p>The levels plays correctly. From here I can replaceScene to go back to the menu, and then back to a level with no problem. However, things do not work when I try to restart a level. To restart, I call:<br />
<code><br />
[appDelegate nextLevel];<br />
</code></p>
<p>This should reset the scene, and start it again. However, what I see is the scene in its initial state, but there is no physics behavior, and my <code>tick:</code> function only gets called once. For example, I have a ball that should fall when the level starts. When I restart, the ball is at the top of the screen but never falls.</p>
<p>So, I have a world, my sprites, and my bodies. I suspect I am not handling them correctly between the init, reset, and dealloc methods.</p>
<p>For example, right now, in init, I am simply adding a menu to the scene.<br />
In reset, I am removing the sprites and bodies and setting them to nil. Then I delete the world, then recreate the world and add the sprites and bodies to it.<br />
In dealloc, I remove the sprites and bodies and set them to nil, then delete the world.</p>
<p> Can anyone offer some insight into how this should be handled? I have seen some examples of resetting levels with cocos2d, but not when box2d is used as well.</p>
<p>Thanks so much.
</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>NOG on "Where is the position defined for the FPSLabel?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28386#post-139733</link>
			<pubDate>Mon, 16 Jan 2012 19:32:19 +0000</pubDate>
			<dc:creator>NOG</dc:creator>
			<guid isPermaLink="false">139733@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm interested in having labels and parallax backgrounds displayed outside of a scene, and currently checking out CCDirector to see how the frames per second are displayed.  Can anyone tell me where the label is positioned and added? Thanks
</p></description>
		</item>
		<item>
			<title>alokin on "transition (replaceScene) problem"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/27930#post-137134</link>
			<pubDate>Thu, 29 Dec 2011 02:27:10 +0000</pubDate>
			<dc:creator>alokin</dc:creator>
			<guid isPermaLink="false">137134@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>I am having a problem with scene transitions. What seems to be happening is after I call a function to do a scene transition, during the 0.5 seconds of transition time (which I set), the main loop of the current scene still runs, which can cause some quirky problems. Here is an example of some code which produces some weird results (but inevitably works):</p>
<p>- (void) update : (ccTime) delta<br />
{<br />
    ...</p>
<p>    if ([computer hp] &#60;= 0)<br />
    {<br />
        [self gotoUserWinsLayer];<br />
    }<br />
}</p>
<p>…</p>
<p>- (void) gotoUserWinsLayer<br />
{<br />
    // go to the UserWinsLayer scene<br />
    [[CCDirector sharedDirector] replaceScene :<br />
	 [CCTransitionFade transitionWithDuration : 0.5f<br />
                                        scene : [UserWinsLayer scene]]];<br />
}</p>
<p>So here, "replaceScene" is called several times awkwardly since the "update" method is still being called during the 0.5 seconds of transition time.. This is probably a n00b question, hopefully I'm just being stupid. Any help would be greatly appreciated.</p>
<p>Thanks,<br />
Nikola
</p></description>
		</item>
		<item>
			<title>glacialspring on "How to replace scene when applicationWillResignActive is called"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/27771#post-136432</link>
			<pubDate>Wed, 21 Dec 2011 12:18:59 +0000</pubDate>
			<dc:creator>glacialspring</dc:creator>
			<guid isPermaLink="false">136432@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I would like to replace the scene with a splash/loading screen (necessary for content updating and loading from server) in applicationWillResignActive when the home button is pressed. However, when I open the app again, there is a delay before the scene is changed so that the scene before the splash screen is still visible for a little bit.<br />
my code:<br />
<code><br />
- (void)applicationWillResignActive:(UIApplication *)application {<br />
    [[CCDirector sharedDirector] replaceScene:[SplashScreen scene]];<br />
    [[CCDirector sharedDirector] pause];<br />
    [[Networking sharedManager] disconnect];<br />
}</p>
<p>- (void)applicationDidBecomeActive:(UIApplication *)application {<br />
	[[CCDirector sharedDirector] resume];<br />
    [[Networking sharedManager] authenticateLocalUser];<br />
}</p>
<p>-(void) applicationDidEnterBackground:(UIApplication*)application {<br />
	[[CCDirector sharedDirector] stopAnimation];<br />
}</p>
<p>-(void) applicationWillEnterForeground:(UIApplication*)application {<br />
	[[CCDirector sharedDirector] startAnimation];<br />
}<br />
</code>
</p></description>
		</item>
		<item>
			<title>sg1 on "BP for avoiding retain cycles in scene transitions"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25483#post-132629</link>
			<pubDate>Sat, 10 Dec 2011 20:30:54 +0000</pubDate>
			<dc:creator>sg1</dc:creator>
			<guid isPermaLink="false">132629@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a scene, correctly added and later removed from the hierarchy via -replaceScene:.  Unfortunately, even after being removed, the scene is never released.  A little digging revealed that [self runAction:(a CCFollow action)] was retaining "self" - the scene.</p>
<p>In -dealloc, I had added [self removeFollowAction], in anticipation of the need to remove it.  However, it appears that this is technically a retain cycle now: since the action is retaining self, self never deallocs and removes the action.  Hence never being released.</p>
<p>My question is: what would your advice be for the best practice for overcoming this issue?</p>
<p>Should I deliberately add a [scene cancelAllActions] to:</p>
<pre><code>CCScene *scene = [IntroLayer scene];
        //Add a [oldScene cancelAllActions] here;
	CCTransitionFade *transition = [CCTransitionFade transitionWithDuration:0.5f scene:scene withColor:ccBLACK];
	[[CCDirector sharedDirector] replaceScene:transition];</code></pre>
<p>I am also worried that there are other elements which may retain the parent in this fashion.  It would seem to me that -replaceScene: would automatically call cancelAllActions and removeFromParent:cleanup:YES; is this not the case?  Do I need to 'retain' actions I want to cancel later, or simply 'assign' them?</p>
<p>I found this, which skirts the issue: <a href="http://www.cocos2d-iphone.org/forum/topic/22983" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/22983</a></p>
<p>Any further illumination would be appreciated.  Thank you!
</p></description>
		</item>
		<item>
			<title>NOG on "CCTransitionFade: fade first, then load?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/24802#post-130800</link>
			<pubDate>Fri, 02 Dec 2011 19:25:50 +0000</pubDate>
			<dc:creator>NOG</dc:creator>
			<guid isPermaLink="false">130800@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've been making a game for quite a while, and while it runs very nicely, some maps are large, and transitioning between scenes sometimes hangs a bit before the fade transition starts. What irks me about this is why it is designed like this in the first place. Shouldn't it handle the fade transition before it starts loading the next scene?  </p>
<p>Anyway, anyone know a good way around this? Alternatives?  I'd just like it to fade to black first, and then load the next scene while the screen is still black.</p>
<p>I've tried the CCFade action on self with no luck, but maybe I'm using it wrong.
</p></description>
		</item>
		<item>
			<title>cr201 on "Sprites disappear after Level Change"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/24706#post-130170</link>
			<pubDate>Tue, 29 Nov 2011 14:59:21 +0000</pubDate>
			<dc:creator>cr201</dc:creator>
			<guid isPermaLink="false">130170@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>this is my first post on this forum. </p>
<p>The basic concept of my App is that sprites move along a certain path and at a certain sequence, and u have to hit them at the right time. This is working fine, when I initially start the game. I implemented the option to go back to main menu and select a new level. Basically only the sequence of the objects change in this different level. But the objects never appear on screen, and dont behave according to their lifecycle.</p>
<p>Here is the Code:</p>
<pre><code>//1. implements delegate from GomeLogicManager, creates Sprites that move along a certain path.
-(void)playNoteByID:(int)noteToPlay :(ccTime)now{
    Note* note = [[GameLogicManager sharedInstance].notesArray objectAtIndex:noteToPlay];
        CCSprite *noteSprite = [CCSprite spriteWithTexture:note.texture];
        noteSprite.position = ccp(-150, 0);
        noteSprite.tag = note.counter;
        int duration = 3;
        id actionMove = [CCMoveTo actionWithDuration:duration position:ccp(250,0)];
        id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
        [noteSprite runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];
        [foreGround addChild:noteSprite];
}

//2. remove Sprite from Screen
-(void)spriteMoveFinished:(id)sender{
    [self.foreGround removeChild:sender cleanup:YES];
    sender = nil;
}

//3. Quit and go to main Menu, remove all delegates + clean up then go to Main Menu
-(void)quit{
    [self.foreGround removeAllChildrenWithCleanup:YES];
    [[CCScheduler sharedScheduler] unscheduleAllSelectors];
    [[SimpleAudioEngine sharedEngine] stopBackgroundMusic];
    [GameLogicManager sharedInstance].delegate = nil;
    [[CCDirector sharedDirector] replaceScene: [MainMenuScene node]];
}</code></pre>
<p>On the first run everything works out fine. Sprites get created and destroyed when done with their Movement. If I call [self quit] it seems to clean up fine and switches to the Main Menu. On the next Level selected 1. gets called, but the Sprite never appears on the Screen. In addition to this, 2 never gets called. The compiler comes up with no errors. I guess it is a Memory Issue, but I couldn't figure out anything yet. Am I missing something?
</p></description>
		</item>
		<item>
			<title>phantomsri on "exclamation mark on replace scene"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22986#post-127044</link>
			<pubDate>Sun, 20 Nov 2011 13:35:36 +0000</pubDate>
			<dc:creator>phantomsri</dc:creator>
			<guid isPermaLink="false">127044@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi i need advice, previously before running in ios4, i dont receive this error.<br />
But after apple release the ios5 with new xcode i get this exclamation mark.</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;HelloWorldLayer&#34;
#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;GameLayer&#34;

.
.
.
    CCScene *levelOne = [[[GameLayer alloc] initWithTile:2] autorelease];
//this is where the exclamation mark i receive= &#34;receive incompatible pointer types initialization &#34;CCScene *&#34; with an expression of type &#34;GameLayer *&#34; &#34;

    [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInR transitionWithDuration:0.5 scene:levelOne]];

.
.
.</code></pre>
<p>so far when run the app it will launch. Does anyone know how to solve this issue?
</p></description>
		</item>
		<item>
			<title>dgtheman on "Do too many updates take up too much memory?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22659#post-125685</link>
			<pubDate>Sat, 12 Nov 2011 07:12:43 +0000</pubDate>
			<dc:creator>dgtheman</dc:creator>
			<guid isPermaLink="false">125685@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a lot of updates running at once in my app. These updates are categorized for the important sprites in my game, so the Ais are running their own update, a cabinet which generates random loot and is opened when tapped is going through its own update, etc. Does this take up too much memory? Because on a 2g ipod the app gives a memory warning level = 2 when in the main city (with the most sprites in the scene at once) and gives a memory warning level = 1 when the updates for some major sprites are remove. Pretty much Im trying to ask if it is worth it to almost destroy my way of organization and only update in one scene...so run only one update and pass in every sprite's data in that one update. This would take a very long time and I would have to restructure a lot of well organized code. Thats why I really want to know if it is worth doing so. I want to make this app playable on the ipod 2g with no memory issues and if I need to do this then I will. Also, here is some more background info that is contributing to the memory issues. I would like to know if I can resolve these issues instead of the update issue which does not fix the whole thing anyway...</p>
<p>1.)I have 11 plists loaded in at once (each 1024 x 1024) and I will need some frames from each of them in the scene at one time. Should I organize it so that I use less? If so how many should be in the scene at once?</p>
<p>2.)I have a lot of arrays initalized at the beginning of the game. Should I restructure my code to get rid of all these arrays? The arrays contain CCSprites and b2Bodys (pointers)</p>
<p>3.) I have a NSDictionary thats stores a lot of NSNumbers. I had posted another question regarding whether or not these take up too much memory and almost evreyone said that unless you are storing 1 million of them it will ot matter. I am only storing maybe 200.</p>
<p>4.)I have some global variables that need to be retained (including arrays and ccsprites) should I somehow get rid of these global variables? I know its not good practice to use them but I did not know this when I first started programming my game....Also, if possible this option should be ruled out because I need the GameScene layer and the hero sprite as global variables no matter what...</p>
<p>Thanks for any suggestions!!
</p></description>
		</item>
		<item>
			<title>firephysics on "replace scene?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22559#post-125201</link>
			<pubDate>Wed, 09 Nov 2011 15:20:44 +0000</pubDate>
			<dc:creator>firephysics</dc:creator>
			<guid isPermaLink="false">125201@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey guys I was wondering if someone could clarify this for me. When you replace a scene is just the scene and the children of the scene released. or is everything released (variables that havent been added as children)?
</p></description>
		</item>
		<item>
			<title>bvarasse on "Adding a score layer to the main scene"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22036#post-122495</link>
			<pubDate>Sat, 22 Oct 2011 12:08:21 +0000</pubDate>
			<dc:creator>bvarasse</dc:creator>
			<guid isPermaLink="false">122495@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi Everybody</p>
<p>I have a scene that i get the static member by:</p>
<p><code></p>
<p>+(id) scene<br />
{<br />
    CCScene *scene = [CCScene node];<br />
   [scene addChild:[Game node] z:0 tag:GAME_TAG];<br />
    return scene;<br />
}<br />
</code></p>
<p>I also have a ScoreLayer class, subclass of CCLayer that is done that way:</p>
<p><code><br />
@implementation ScoreLayer</p>
<p>-(id) initWithTarget:(Target *)_target{<br />
    self = [super init];<br />
    if (!self) {<br />
        return nil;<br />
    }<br />
    target=_target;<br />
    return self;<br />
}</p>
<p>-(void) setUp{<br />
    int w=self.contentSize.width;<br />
    int h=self.contentSize.height;<br />
    UIImage *img=[UIImage imageNamed:[target getRetina:[NSString stringWithFormat:@"sc0"]]];<br />
    int scw=(img.size.width/[target getScale])/1;<br />
    int sch=(img.size.height/[target getScale]);<br />
    sc1=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc2=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc3=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc4=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc5=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc6=[CCSprite  spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:[target getUnRetina:[NSString stringWithFormat:@"sc0"]]] rect:CGRectMake(0, 0, scw,sch)];<br />
    sc1.position=CGPointMake(w-scw,h-sch/2);<br />
    sc2.position=CGPointMake(w-scw*2,h-sch/2);<br />
    sc3.position=CGPointMake(w-scw*3,h-sch/2);<br />
    sc4.position=CGPointMake(w-scw*4,h-sch/2);<br />
    sc5.position=CGPointMake(w-scw*5,h-sch/2);<br />
    sc6.position=CGPointMake(w-scw*6,h-sch/2);<br />
    [self addChild:sc1 z:1];<br />
    [self addChild:sc2 z:1];<br />
    [self addChild:sc3 z:1];<br />
    [self addChild:sc4 z:1];<br />
    [self addChild:sc5 z:1];<br />
    [self addChild:sc6 z:1];<br />
    NSLog(@"score added");<br />
}</p>
<p>-(void) dealloc {<br />
    [super dealloc];</p>
<p>}<br />
@end<br />
</code></p>
<p>the problem is to add the score layer to the main scene so it overlap the game node<br />
I tried in the Game init method:</p>
<p><code><br />
target=[[Target alloc] init];<br />
sclayer=[[ScoreLayer alloc] initWithTarget:target];<br />
[sclayer setUp];<br />
CCScene *scene = [CCScene node];<br />
[scene addChild:[ScoreLayer node] z:1000 tag:SCORE_TAG];<br />
//[scene addChild:sclayer z:1000 tag:SCORE_TAG];</p>
<p></code><br />
i tried adding sclayer and [SCLayer node] without success</p>
<p>Unfortunately the score layer doesn't appear on the top of the game scene<br />
If i add it as a child of the game scene, it shows ok, but unfortunately i have a zoom in the game scene that interfer then with the score layer, so i cannot leave it that way.</p>
<p>Any idea how to add the score layer to the main scene. Many thanks for the help,</p>
<p>Benoit - France
</p></description>
		</item>
		<item>
			<title>iclem on "Reference variables from scene to scene"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21973#post-122146</link>
			<pubDate>Thu, 20 Oct 2011 00:12:27 +0000</pubDate>
			<dc:creator>iclem</dc:creator>
			<guid isPermaLink="false">122146@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>so my problem is that I need to use my main scene's child class function, from another child of the main scene. in other words I have 3 scenes, levelOneScene extending from LevelScene and LevelCompleteScene extending from LevelScene. I need to load the next level upon pressing the next level function. I was going to store the next level in each of my level scenes. Thus, when the player taps the "Next Level" button in my Level complete scene, I need to call nextLevel function in my levelOneScene. How might I go about doing this? If this is not the ideal way of doing this, what might be the best way?
</p></description>
		</item>
		<item>
			<title>Dynex on "How to use a single spritesheet for all scenes"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21813#post-121148</link>
			<pubDate>Fri, 14 Oct 2011 00:08:08 +0000</pubDate>
			<dc:creator>Dynex</dc:creator>
			<guid isPermaLink="false">121148@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey guys,</p>
<p>Right now I have this is my main gamescene:<br />
<pre><code>//Cache the sprite frames and texture
		[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@&#34;UltimateSheet.plist&#34;];
UltimateSpriteSheet = [CCSpriteBatchNode batchNodeWithFile:@&#34;UltimateSheet.png&#34;];  //ADDING SPRITESHEET PNG**********
		[self addChild:UltimateSpriteSheet z:17];</code></pre>
<p>And this is my delloc:<br />
<pre><code>[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];</code></pre>
<p>When I try to add other sheets to other scenes (post game scene, pregame) i get errors. What would be the best way to go about this? All scenes have mutiple small images, and I'd like to take full advantage of spritesheets. </p>
<p>One problem that I'm going to run into is, I need a scene pushed on top of another scene. Can I still use spritesheets with both scenes?
</p></description>
		</item>
		<item>
			<title>reflashed on "Global GUI (above scene)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8071#post-47012</link>
			<pubDate>Tue, 20 Jul 2010 22:05:23 +0000</pubDate>
			<dc:creator>reflashed</dc:creator>
			<guid isPermaLink="false">47012@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>What do you guys think would be best practice for having a global GUI in a game? For instance let's say I have a mute button that I want to appear on each of my menus and in-game. Each menu is its own scene as well as the in-game scene. I could recreate the global GUI in each scene, but that seems like a bit overkill, and wouldn't work well with transitions. Is there any easy way to have this global GUI reside on top of each scene?
</p></description>
		</item>
		<item>
			<title>VanTheManiac on "Advice on best practice using Scene and Layers - updating a score layer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21501#post-119474</link>
			<pubDate>Tue, 04 Oct 2011 06:59:20 +0000</pubDate>
			<dc:creator>VanTheManiac</dc:creator>
			<guid isPermaLink="false">119474@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
I'm working on my first Cocos-game and doing progress everyday but I need some advice on how to use layers properly and how to call methods on them.</p>
<p>My game will have several scenes (intro, menu, level1, level2,level3 etc).<br />
On each level scene I'll have one layer handling the gameplay for that level.<br />
I'm thinking on having a ScoreLayer that I put on top on each level-layer to make the score and # lives visible. I'll have a few methods on this layer to do the init and update etc.</p>
<p>Is this the proper way to think about Scene's and Layers?<br />
For example in the Scene init method for level 1:</p>
<p>        level1Layer = [Level1Layer node];<br />
        [self addChild:level1Layer z:5];</p>
<p>        scoreLayer = [ScoreLayer node];<br />
        [self addChild:scoreLayer z:100];</p>
<p>And now for the most important question, how to I call the updateScore-method in ScoreLayer from Level1Layer?
</p></description>
		</item>
		<item>
			<title>goodeats2009 on "Sticky Button Not responding to click help"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/20734#post-115248</link>
			<pubDate>Sat, 10 Sep 2011 17:19:59 +0000</pubDate>
			<dc:creator>goodeats2009</dc:creator>
			<guid isPermaLink="false">115248@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hi,  i created a sticky button for the purpose of using it as a "End of Turn" button for a turn based game.  The problem is when i click it, it does not respond to anything when i click it.  I have a scene where i added the gameplayLayer and the HUDLayer (this is where the stickyButton is created)</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;GameScene.h&#34;

@implementation GameScene

- (id)init
{
    self = [super init];
    if (self) {
        //HUD Layer
        playHUDLayer = [HUDLayer node];
        [self addChild:playHUDLayer z:5];
        if (playHUDLayer.endTurnButton.active) {
            CCLOG(@&#34;button pressed&#34;);
        }

        //HelloWorld Layer
        gamePlayLayer = [HelloWorldLayer node];
        [self addChild:gamePlayLayer z:4];
    }

    return self;
}

@end</code></pre>
<p>this is the implementation of the HUDLayer<br />
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;HUDLayer.h&#34;

@implementation HUDLayer
@synthesize endTurnButton;

-(void) initButtons {
    CGSize screenSize = [[CCDirector sharedDirector]winSize];
    CGRect endTurnButtonDimension = CGRectMake(0, 0, 64.0f, 64.0f);
    CGPoint endTurnButtonPosition;

    endTurnButtonPosition = ccp(screenSize.width*0.11f, screenSize.height*0.11f);

    SneakyButtonSkinnedBase *endTurnButtonBase = [[[SneakyButtonSkinnedBase alloc]init]autorelease];
    endTurnButtonBase.position = endTurnButtonPosition;
    endTurnButtonBase.defaultSprite = [CCSprite spriteWithFile:@&#34;jumpUp.png&#34;];
    endTurnButtonBase.activatedSprite = [CCSprite spriteWithFile:@&#34;jumpDown.png&#34;];
    endTurnButtonBase.pressSprite = [CCSprite spriteWithFile:@&#34;jumpDown.png&#34;];
    endTurnButtonBase.button = [[SneakyButton alloc]initWithRect:endTurnButtonDimension];
    endTurnButton = [endTurnButtonBase.button retain];
    endTurnButton.isToggleable = NO;
    [self addChild:endTurnButtonBase];
}

- (id)init
{
    self = [super init];
    if (self) {
        self.isTouchEnabled = YES;
        [self initButtons];
        CCLOG(@&#34;HUDLayer initialized&#34;);

    }

    return self;
}

@end</code></pre>
<p>And in the gamePlayLayer i created an instance of the HUDLayer and tried to make it respond by adding this code:<br />
<pre><code>HUDLayer *endTurnButton;

if (endTurnButton.endTurnButton.active)

 { do something}</code></pre>
<p>how do i make this button work?  </p>
<p>i included a screenshot, the button is in the lower left corner.<br />
<a href="http://www.flickr.com/photos/67382033@N02/6133122337/in/photostream" rel="nofollow">http://www.flickr.com/photos/67382033@N02/6133122337/in/photostream</a></p>
<p> thanks
</p></description>
		</item>
		<item>
			<title>Bongeh on "Making a transparent pause menu"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4368#post-26069</link>
			<pubDate>Tue, 09 Feb 2010 09:35:21 +0000</pubDate>
			<dc:creator>Bongeh</dc:creator>
			<guid isPermaLink="false">26069@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I want to make a pause menu that appears when i pause my game.</p>
<p>I understand that there are several things here i can use.</p>
<p>I could 'push' the old scene making my current scene freeze and bringing in a new one</p>
<p>	PauseScene *ps = [PauseScene node];<br />
	[[CCDirector sharedDirector] pushScene:ps];	</p>
<p>the only problem here is the old scene is not left in the background, its hidden away in memory.</p>
<p>I can pause the game using the following command</p>
<p>[[CCDirector sharedDirector] pause];</p>
<p>and then pull in a new layer to the current scene.</p>
<p>although i think touches may pass onto the gamescene that is paused behind and 'stack up' so that when you unpause, it may do lots of things you did not expect.</p>
<p>What is the correct way to do this? or a suggested way that someone has found works and is wiling to share?
</p></description>
		</item>
		<item>
			<title>mruffa on "replaceScene - problem"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18931#post-106147</link>
			<pubDate>Thu, 21 Jul 2011 08:16:11 +0000</pubDate>
			<dc:creator>mruffa</dc:creator>
			<guid isPermaLink="false">106147@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey </p>
<p>When I call replaceScene I got only white blank view. All things like Network stuff, touch callbacks are working, but Cocos seems to have problem with displaying graphics on Layer. My Class inherites CClayer.</p>
<p>I use Cocos2D 1.0.0. Can anybody please help me with that? :)</p>
<p>thanks!
</p></description>
		</item>
		<item>
			<title>phantomsri on "loading scene problem"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/17260#post-97203</link>
			<pubDate>Sat, 04 Jun 2011 15:17:35 +0000</pubDate>
			<dc:creator>phantomsri</dc:creator>
			<guid isPermaLink="false">97203@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, I have a game, with 2 layer.<br />
the first layer there is 2 icons, when i touch the first icon it will load the second layer(game layer) with tilemap one.<br />
when i touch the second icon it will load the second layer with tilemap two.</p>
<p>i have created </p>
<pre><code>-(void) tileMapOne
{
//tile map first level code
}

-(void) tileMapTwo
{
//tile map second level code
}</code></pre>
<p>I have used this code to load the scene<br />
<pre><code>GameScene *gameOverScene = [GameScene node];
        [[CCDirector sharedDirector] replaceScene:gameOverScene];</code></pre>
<p>My questions is, is there a way to write a code where when i load the new scene it can load the -(void) tileMapOne method when click icon 1. and when i click icon 2 it loads<br />
the new scene with -(void) tileMapTwo.</p>
<p>i hope some one can advice me coz im a little new to cocos2d
</p></description>
		</item>
		<item>
			<title>Mettich on "Design Pattern - Singleton or many Scenes?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18573#post-104183</link>
			<pubDate>Mon, 11 Jul 2011 18:28:40 +0000</pubDate>
			<dc:creator>Mettich</dc:creator>
			<guid isPermaLink="false">104183@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>I have a design question. I have an App with different levels. I can think of two ways to achieve this:</p>
<p>1. Make a singleton, which hold the currently selected level. Then in the game class, the logic is held. Within this class i setup every level according the currently selected level. The disadvantage is, that the setup section gets somehow huge.</p>
<p>2. Make a new scene for every level. This way the setup for every level is clear. the disadvantage is, that the logic is redundant. Thus changing game logic needs to be done more than once.</p>
<p>Which is the best approach? Is there even a better one, than the two above?<br />
Best regards,<br />
Mettich
</p></description>
		</item>
		<item>
			<title>sanch on "Multiple scene and importing c++ problem."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19075#post-106931</link>
			<pubDate>Mon, 25 Jul 2011 17:15:43 +0000</pubDate>
			<dc:creator>sanch</dc:creator>
			<guid isPermaLink="false">106931@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello<br />
I'm having a problem i can't understand , and so i'm posting here after many search on the forum.<br />
I got my small game with 2 scene on 2 different file<br />
i got StartMenu and GameScene<br />
In my game scene  i got box2D running fine and i want to import it as well in my StartMenu file to do some background animation with it , i got .mm extension to be able to use c++ inside my startmenu.<br />
 as soon as i import the box2D.h in startmenu.h the project won't compile , i got 300+ error , like it do when you don't have the .mm extension , i don't have problem with GameScene/box2d and both file are in the same folder. I just have a single button "start" in startmenu launching gamescene , and gamescene got one to go back to startmenu.<br />
note that if i import my box2D in the startmenu.mm i don't have problem.<br />
I'm using xcode4 with last cocos2D.<br />
Any Idea?
</p></description>
		</item>
		<item>
			<title>dgtheman on "How to remove a layer from a scene then add another one in its place?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18993#post-106524</link>
			<pubDate>Sat, 23 Jul 2011 00:58:40 +0000</pubDate>
			<dc:creator>dgtheman</dc:creator>
			<guid isPermaLink="false">106524@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I know it is possible to replace a scene in cocos2d but is it possible to do the same thing with a layer. For example, I have two layers one called GameLayer and one called RoomLayer and I want to remove the GameLayer putting RoomLayer in its place. I could not find any specific topics on this. I already know to remove the GameLayerI would just do<br />
<code>[[Scene scene]removeChild:GameLayer cleanUp:YES]</code><br />
But when I do<br />
<code>[[Scene scene]addChild:RoomLayer]</code><br />
The RoomLayer is not added.<br />
-Thanks for any help
</p></description>
		</item>
		<item>
			<title>ModeSix on "Problem Using Scene Transitions"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18992#post-106522</link>
			<pubDate>Sat, 23 Jul 2011 00:40:01 +0000</pubDate>
			<dc:creator>ModeSix</dc:creator>
			<guid isPermaLink="false">106522@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I am having a particularly annoying issue when using scene transitions to replace a scene.</p>
<p>If I do a standard replaceScene with no transition everything works perfectly fine.</p>
<p>When I am restarting my main gamescene with a transition I am encountering some very strange behaviour.</p>
<p>If I replace scene with the existing scene (a simple game restart), my sprites used for my parallax node are not being initialized properly to their starting position.</p>
<p>If I replace scene to an end game scene using a transition, and having that scene replaceScene without transition back to the Gamescene I am given nothing but a black screen.  The game is running, as I can hear the music playing, but I see nothing but a black screen.  It appears the endscene us not unloading.</p>
<p>I am transitioning to the endscene using the following:<br />
<pre><code>-(void)restartTapped:(id)sender {

    CCTransitionFlipY *action = [CCTransitionPageTurn transitionWithDuration:0.5 scene:[EndScene scene]];
    [[CCDirector sharedDirector] replaceScene:action];
}</code></pre>
<p>My EndScene is as follows:<br />
<pre><code>@implementation EndScene

+(id)scene {

    CCScene *scene = [CCScene node];
    EndScene *layer = [EndScene node];
    [scene addChild:layer];

    return scene;
}

-(void)replaceScene{
    [[CCDirector sharedDirector] replaceScene:[GameScene scene]];
}

-(id)init {

    if ((self = [super init])) {

      [self replaceScene]; 

    }
    return self;

}

-(void)dealloc {

    [super dealloc];
}

@end</code></pre>
<p>What am I doing wrong in this instance?  </p>
<p>To reiterate, if I do not use a scene transition, it works perfectly.  I am only encountering this problem when using replace scene with transition.</p>
<p>If I reset straight to my GameScene the parallax node doesn't initialize properly (and I can only assume other less visible things are not initializing properly).</p>
<p>If I flip to endscene and back to gamescene I see nothing but a black screen.</p>
<p>I am only using the EndScene to find a solution to this problem, ideally I would like to use the following code in my GameScene.m</p>
<pre><code>-(void)restartTapped:(id)sender {

    CCTransitionFlipY *action = [CCTransitionPageTurn transitionWithDuration:0.5 scene:[GameScene scene]];
    [[CCDirector sharedDirector] replaceScene:action];
}</code></pre>
<p>I am using Cocos2D 1.0.0, the current release version.
</p></description>
		</item>

	</channel>
</rss>

