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

		<item>
			<title>JohnTaylor on "How does one create a transparent director view for the Mac?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/14631#post-83069</link>
			<pubDate>Thu, 17 Mar 2011 21:19:12 +0000</pubDate>
			<dc:creator>JohnTaylor</dc:creator>
			<guid isPermaLink="false">83069@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>There are numerous postings in the forum for how create a transparent director view for iOS projects, for example:</p>
<p><a href="http://www.cocos2d-iphone.org/forum/topic/9587" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/9587</a></p>
<p>However I've not been able to find any documentation on how one would create a transparent director view for a Mac project.</p>
<p>I'm able to create a transparent window using the following code:</p>
<pre><code>[window_ setStyleMask:NSBorderlessWindowMask];
[window_ setBackgroundColor:[NSColor clearColor]];
[window_ setOpaque:NO];</code></pre>
<p>placed before:</p>
<p><code>CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];</code></p>
<p>but after this I'm at a loss. I'm guessing some tweaking of the CCDirectorMac class and maybe the MacGLView class are needed, however my openGL programming skills are lacking to work out what I need to do.</p>
<p>Can some kind soul explain how one would take the 'cococs2d application - mac' template project and make the 'Hello World' text appear on a transparent background.</p>
<p>I'm using cocos2d 1.0.0.
</p></description>
		</item>
		<item>
			<title>SoundBlaster on "&#039;ReplaceScene&#039; and memory management"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22065#post-122615</link>
			<pubDate>Sun, 23 Oct 2011 09:31:14 +0000</pubDate>
			<dc:creator>SoundBlaster</dc:creator>
			<guid isPermaLink="false">122615@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello!<br />
I create the interactive book for iPad.<br />
To turn the pages I use:<br />
<code>[[CCDirector sharedDirector] replaceScene:[pageClass scene]];</code><br />
I don't have any leaks, but I have notice the memory problem.<br />
For example, in my test project  I have 3 pages: first page has 1 picture (1024*768), scene of second picture if free of any child, and third page is also free.<br />
When CCDirector places first scene, allocated memory is around 11 MB.<br />
When first scene is replaced by second scene, there is also 11MB.<br />
And when second scene is replaced by third scene memory go to 8 MB, that is normal for my page without child.<br />
All methods like <code>dealloc</code> <code>onEnter</code> <code>onExit</code> are called properly.</p>
<p>In my real project every page needs around 20-30 MB of memory (I use big atlases). Simultaneous storage of 3 pages in memory calls memory warnings and causes crashing my app, because my iPad 1 doesn't have enough free memory.</p>
<p>Is it bug of Cocos?<br />
May be I do somethings wrong? Where I can read about runloop of cocos2d scene?
</p></description>
		</item>
		<item>
			<title>robodude666 on "Director Types?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7280#post-42669</link>
			<pubDate>Mon, 21 Jun 2010 16:42:55 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">42669@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey guys,</p>
<p>What is the primary difference between each of the different Director Types? I know there are 4 of them:</p>
<p>CCTimerDirector - Uses an NSTimer<br />
CCDisplayLinkDirector - Uses CADisplayLink<br />
CCFastDirector - Uses NSInvocation<br />
CCThreadedFastDirector - Uses NSThread</p>
<p>What is the best use for each one of them? From playing around I discovered:</p>
<p>CCTimerDirector works best with UIView elements like UIScrollView with a small modification to <code>CCDirector.m</code>, though it's a little slow.</p>
<p>CCDisplayLinkDirector uses CADisplayLink which is recommended by Apple for OS 3.1+ devices as it's the fastest, though it freezes with UIScrollView elements.</p>
<p>The CCFastDirector works with UIScrollView elements except it breaks the momentum scroll,</p>
<p>And lastly the CCThreadedFastDirector is in between the timer director and display link in terms of performance, with native support for UIScrollView elements.</p>
<p>Which is best for what, and which should be avoided altogether? I'm only testing on a Simulator now, so I can't exactly see if the results translate to a device.</p>
<p>-robodude666
</p></description>
		</item>
		<item>
			<title>gaminghorror on "Its possible to save ENTIRE Director State (actions, sprites on screen, etc)?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8191#post-47668</link>
			<pubDate>Sun, 25 Jul 2010 08:49:14 +0000</pubDate>
			<dc:creator>gaminghorror</dc:creator>
			<guid isPermaLink="false">47668@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You could try your luck and implement the aspect-oriented programming technique described here which basically adds NSCoding support to other classes:<br />
<a href="http://davedelong.com/blog/2009/04/13/aspect-oriented-programming-objective-c" rel="nofollow">http://davedelong.com/blog/2009/04/13/aspect-oriented-programming-objective-c</a>
</p></description>
		</item>
		<item>
			<title>Ozden79 on "Reset Director time?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/16627#post-93721</link>
			<pubDate>Mon, 16 May 2011 17:30:04 +0000</pubDate>
			<dc:creator>Ozden79</dc:creator>
			<guid isPermaLink="false">93721@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello There,</p>
<p>During my gameplay, when I switch a level for example, I'm loading some assets or creating some sprites. This causes a delay in game time. This is not a problem but more importantly, the actions I start during that process, seems to skip that delay in time so some of my animations seems to work like from the middle, like "Get Ready" logo moving into the screen. I think to solve this problem, I need to reset the game time so the actions can start from the beginning.</p>
<p>I could do this in other systems, such as "ResetElapsedTime" on XNA and would like to know whether we have the same feature in Cocos2d as well?</p>
<p>Thanks in advance...</p>
<p>Özden
</p></description>
		</item>
		<item>
			<title>iisystems on "Sprite flicker in transition when migrating to 0.99"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/9714#post-55874</link>
			<pubDate>Mon, 20 Sep 2010 06:18:07 +0000</pubDate>
			<dc:creator>iisystems</dc:creator>
			<guid isPermaLink="false">55874@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I recently migrated my project to 0.99x from 0.8x.  I use transitions between scenes such as:<br />
<pre><code>[[CCDirector sharedDirector] replaceScene: [CCFlipYTransition transitionWithDuration:0.5f scene:gs orientation:kOrientationUpOver]];</code></pre>
<p>These transitions didn't cause me any problems in 0.8x.  Even using UIKit elements, they worked fine.  Now, in 0.99x, my sprites flicker as the transition effect occurs.  I have tried all four directors; all have the same problem.<br />
<pre><code>//[CCDirector setDirectorType:kCCDirectorTypeDisplayLink];
	//[CCDirector setDirectorType:kCCDirectorTypeMainLoop];
	//[CCDirector setDirectorType:kCCDirectorTypeNSTimer];
	[CCDirector setDirectorType:kCCDirectorTypeThreadMainLoop];</code></pre>
<p>Has anyone else come across this?</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>Martin on "Strange problem with main loop / movement"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/15368#post-87205</link>
			<pubDate>Fri, 08 Apr 2011 02:20:09 +0000</pubDate>
			<dc:creator>Martin</dc:creator>
			<guid isPermaLink="false">87205@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi! I'm having a really strange problem that I just can't fix. I have a singleton that is supposed to manage every game object. It has the update scheduled by<br />
<code>[self scheduleUpdate];</code></p>
<p>This is the complete code of the update method of this object:<br />
<pre><code>-(void) update:(ccTime)delta
{
	float d = delta; 

	for (MovingObject* obj in objectsArray)
	{
		[obj update:d];
	}
	[self collisionChecks];
	[self combat];
}</code></pre>
<p>I think that d = delta makes no sense, right? I added it as a test while trying to solve my problem.<br />
My MovingObject's update method starts like this:</p>
<pre><code>-(void) update:(ccTime)delta
	// trying to factor in the time delta for movement:
	float timeDeltaFactor = delta / ( 1.0f/60.0f );
	// capping it at 4 to avoid warping that kills collision detection
	if (timeDeltaFactor &#62; 4) timeDeltaFactor = 4.0f;
	// currentSpeed and speedMultiplier can be ignored for now, they don&#39;t change atm
	float speedLeft = currentSpeed * timeDeltaFactor * speedMultiplier;

	// this is what I&#39;m testing with now, the real movement code is more complex.
	self.position = getPointInDirectionFromLocationWithDistance(self.angle, self.position, speedLeft);
	speedLeft = 0;</code></pre>
<p>I have MovingObjects that shoot and the projectiles are MovingObjects themselves. I create two next to each other and they should be flying perfectly synchronous, but they don't. Most times but not always the left one is faster, or the right one slower depending on how you see it. But it isn't even an absolute "slower" which would increase the gap between them over time. It's like they start synchronous, after some pixels one of the projectiles starts to lag behind, catches up a little later, lags behind again, but the distance doesn't change noticably over time.<br />
How can this be? How can I debug this?<br />
I thought it might have something to do with how the director works or which type of director I choose. I tried them all out but I can't see a difference.<br />
Any help would be greatly appreciated, I'm stuck on this.
</p></description>
		</item>
		<item>
			<title>akaii on "runWithScene and memory"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2327#post-14628</link>
			<pubDate>Wed, 07 Oct 2009 04:23:10 +0000</pubDate>
			<dc:creator>akaii</dc:creator>
			<guid isPermaLink="false">14628@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>[[Director sharedDirector] runWithScene:[FadeTransition transitionWithDuration:TRANSITION_TIME scene:[FirstScene node] withColor:ccc3(1.0,1.0,1.0)]];</p>
<p>[[Director sharedDirector] runWithScene:[FirstScene node]];</p>
<p>Either of the above seems to cause a leak, at least according to Instruments. I've taken to releasing the first scene at the app delegate's dealloc, doesn't seem to cause any problems, but I'd like to ask what others might have done to deal with this.
</p></description>
		</item>
		<item>
			<title>Clarity on "Stopping music from iPod when launching app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4406#post-26268</link>
			<pubDate>Wed, 10 Feb 2010 23:35:12 +0000</pubDate>
			<dc:creator>Clarity</dc:creator>
			<guid isPermaLink="false">26268@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, </p>
<p>I am relatively new to the cocos2d environment and am encountering the following issue: </p>
<p>- If I launch an application while listening to a song via my iPod, the music does not stop/pause. The music continues to play in the background. </p>
<p>Desired effect:<br />
- To stop/pause music when my application launches</p>
<p>I have searched through this forum &#38; other cocos2d resources to see what the issue is, but have been unsuccessful.  In examining other applications that contain the desired behavior (mentioned above), I have narrowed the issue down to the Director.  While other applications uses the viewController to force this behavior, I have not figured out how to remedy this in the Director.  </p>
<p>Here's a cut-out of my applicationDidFinishLaunching call: </p>
<p>- (void) applicationDidFinishLaunching:(UIApplication*)application<br />
{<br />
	// Init the window<br />
	window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];</p>
<p>	// cocos2d will inherit these values<br />
	[window setUserInteractionEnabled:YES];<br />
	[window setMultipleTouchEnabled:NO];</p>
<p>	// Try to use CADisplayLink director<br />
	// if it fails (SDK &#60; 3.1) use Threaded director<br />
	if( ! [Director setDirectorType:CCDirectorTypeDisplayLink] )<br />
		[Director setDirectorType:CCDirectorTypeDefault];</p>
<p>	// Use RGBA_8888 buffers<br />
	// Default is: RGB_565 buffers<br />
	[[Director sharedDirector] setPixelFormat:kPixelFormatRGBA8888];</p>
<p>	// Default texture format for PNG/BMP/TIFF/JPEG/GIF images<br />
	// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565<br />
	// You can change anytime.<br />
	[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];</p>
<p>	// before creating any layer, set the landscape mode<br />
	[[Director sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeLeft];<br />
	[[Director sharedDirector] setAnimationInterval:1.0/60];<br />
	[[Director sharedDirector] setDisplayFPS:NO];</p>
<p>	// create an openGL view inside a window<br />
	[[Director sharedDirector] attachInView:window];<br />
	[window makeKeyAndVisible];		</p>
<p>	MenuScene *ms = [MenuScene node];<br />
	[[Director sharedDirector] runWithScene:ms];</p>
<p>}</p>
<p>Am I doing something wrong?
</p></description>
		</item>
		<item>
			<title>EmperiorEric on "Auto Pause when leaving Game"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/12709#post-71263</link>
			<pubDate>Tue, 18 Jan 2011 06:24:44 +0000</pubDate>
			<dc:creator>EmperiorEric</dc:creator>
			<guid isPermaLink="false">71263@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Ok so I know that cocos "pauses" the director by default when it leaves the game. and all. Perfect. BUT I have a pause menu that I show when pausing the game and I'd like to show that right when the applicationWillResignActive.  I have it as a nice method in my GameScene and like when they hit the pause button I call it up and it shows a Resume button as well as pause the game. I want that to show when the game closes/get interrupted so the user isn't immediately in the game when they come back but instead they are seeing the resume button and can press it when they are ready.
</p></description>
		</item>
		<item>
			<title>nk on "Getting FPS in game code"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/12636#post-70937</link>
			<pubDate>Sat, 15 Jan 2011 19:32:21 +0000</pubDate>
			<dc:creator>nk</dc:creator>
			<guid isPermaLink="false">70937@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
I'm doing some complicated calculations in my game and although the frame rate is pretty good, I'd like to make sure it doesn't drop because of the calculations. </p>
<p>I was thinking if there was a way to get the fps from the CCDirector while the game is running and check if its below a certain limit and if it is then perform a simpler calculation instead of the more complex one?
</p></description>
		</item>
		<item>
			<title>Ricardo1980 on "Questions about pause/resume when going to background and showing and iAd"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/11755#post-66288</link>
			<pubDate>Wed, 08 Dec 2010 18:12:35 +0000</pubDate>
			<dc:creator>Ricardo1980</dc:creator>
			<guid isPermaLink="false">66288@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi mates!</p>
<p>When going  to background or not, cocos template call pause/resume from Director.</p>
<p>If I use iAd, user can tap banner, and a new view is shown, something similar to send your app to background, so I call:</p>
<p>-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave<br />
{<br />
[[CCDirector sharedDirector] pause];<br />
return YES;<br />
}</p>
<p>-(void)bannerViewActionDidFinish:(ADBannerView *)banner<br />
{<br />
[[CCDirector sharedDirector] resume];<br />
}</p>
<p>The problem is, if user taps banner, app pauses, if in that moment you press HOME, your app goes to background. After that, you use multitaskeng to wake up the app, which is showing a full screen banner, but cocos2d template calls resume and your game continues BUT on top there is a full screen banner. That's a problem. Do you understand me?</p>
<p>Possible solution: Count number of times resume/pause are called by cocos2d engine.</p>
<p>What do you think
</p></description>
		</item>
		<item>
			<title>gaminghorror on "proposed change: CCDirector drawScene method"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4472#post-26629</link>
			<pubDate>Sun, 14 Feb 2010 13:50:06 +0000</pubDate>
			<dc:creator>gaminghorror</dc:creator>
			<guid isPermaLink="false">26629@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I found myself having to redraw the scene right where i am but cocos2d doesn't offer this functionality yet. So i made a change to CCDirector's main loop and extracted a public drawScene method out of it that can be called anytime.</p>
<pre><code>//
// main loop
//
- (void) mainLoop
{
	/* calculate &#34;global&#34; dt */
	[self calculateDeltaTime];
	if( ! isPaused_ )
		[[CCScheduler sharedScheduler] tick: dt];

	/* to avoid flickr, nextScene MUST be here: after tick and before draw */
	if( nextScene )
		[self setNextScene];

	[self drawScene];
}

-(void) drawScene
{
	/* clear window */
    glClear(GL_COLOR_BUFFER_BIT &#124; GL_DEPTH_BUFFER_BIT);

	glPushMatrix();

	[self applyLandscape];

	/* draw the scene */
	[runningScene_ visit];
	if( displayFPS )
		[self showFPS];

	glPopMatrix();

	/* swap buffers */
	[openGLView_ swapBuffers];
}</code></pre>
<p>I'm not aware of any side effects. The only real change to the code flow i made is to call glClear after the tick and nextScene calls, something that ought not make any difference unless in either of those functions something is drawn to the screen.</p>
<p>I need drawScene in cases where i start a CPU intensive task but have to update the screen before that, for example to remove a dialog box from the screen. So instead of using [self schedule ...] with a short interval and waiting for the selector to be called, i call directly [[CCDirector sharedDirector] drawScene]; and start computing. I also had to use this right in the init method of a scene, for example when the new scene is loaded it should already draw itself because it does some heavy initialization and that would cause the old screen still to be shown.
</p></description>
		</item>
		<item>
			<title>patgoto on "Pausing Animation BUT keeping a Scheduled action"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8116#post-47255</link>
			<pubDate>Thu, 22 Jul 2010 09:38:37 +0000</pubDate>
			<dc:creator>patgoto</dc:creator>
			<guid isPermaLink="false">47255@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi all,</p>
<p>When i pause my game, i'd like to pause the director's drawings BUT i'd need to keep one timer alive so that it keeps getting events on a server.</p>
<p>It looks like both pause/resume and startAnimation/stopAnimation also unschedule all TImers.</p>
<p>It prevents me of keeping some background tasks running and cocos2d says no to use NSThread but its own timer so it stuck with that.</p>
<p>Any idea?</p>
<p>thx
</p></description>
		</item>
		<item>
			<title>mcwhite82 on "Refresh Admob ads"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/6458#post-37742</link>
			<pubDate>Mon, 17 May 2010 09:35:48 +0000</pubDate>
			<dc:creator>mcwhite82</dc:creator>
			<guid isPermaLink="false">37742@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, I always get an issue in my game while my Admob view is getting refreshed with a flip: the director doesn't draw for a short time. My game has some reaction play, so it's very annoying, that the screen freezes for short time. Has anyone of you an idea to solve that? Thanks.
</p></description>
		</item>
		<item>
			<title>Arttu Ekholm on "Removing and creating UIViews - works once, crashes second time"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4976#post-29662</link>
			<pubDate>Thu, 11 Mar 2010 14:45:09 +0000</pubDate>
			<dc:creator>Arttu Ekholm</dc:creator>
			<guid isPermaLink="false">29662@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a problem with CCDirector and UIViews</p>
<p>The navigation of my game basically looks like this:<br />
MainScene -&#62; GameOverScene -&#62; HighScoreView(:UIView) --&#62; and back to the MainScene...</p>
<p>HighScoreView opens and closes normally ONCE, but during the second round of the game, the program quits when it should load HighScoreView again. No error messages, nothing.</p>
<p>HighScoreView is at the moment simple UIView with one button that calls closeHighScoreViewAndStartNewGame method to hide the view and move to the next scene.</p>
<p>Methods in my AppDelegate:</p>
<p>// there's global variable HighScoreView * hs</p>
<pre><code>-(void)openHighScoreView {

	GameOverView *tempView = [[HighScoreView alloc] init];
	selfish = tempView;
	[tempView release];
	[[CCDirector sharedDirector]replaceScene:[MainScene node]];
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:.5];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[[CCDirector sharedDirector] openGLView] cache:YES];
	[[[CCDirector sharedDirector] openGLView] addSubview:go.view];
	[UIView commitAnimations];

}

-(void)closeHighScoreViewAndStartNewGame {

	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:.5];
	[UIView setAnimationDelegate:self];
	[UIView setAnimationDidStopSelector:@selector(animDone:finished:context:)];
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:[[CCDirector sharedDirector] openGLView] cache:YES];
	[hs.view removeFromSuperview];
	[UIView commitAnimations];
	[hs release];
	hs = nil;
}</code></pre>
<p>I let MainScene run in the background because [[CCDirector sharedDirector] resume] somehow crashes the program.</p>
<p>Does anyone know what's wrong in my code and how to fix it? Debugger console shows no error, and neither does try-catch blocks give me any explanation.
</p></description>
		</item>
		<item>
			<title>Billy Lavoie on "Cannot touch UITableView"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4217#post-25279</link>
			<pubDate>Tue, 02 Feb 2010 16:05:25 +0000</pubDate>
			<dc:creator>Billy Lavoie</dc:creator>
			<guid isPermaLink="false">25279@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>When I load my UITableView through the OpenGLView of the director I can't register the touches on my table (the function <code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath</code> never gets called when the table is touched)</p>
<p>If I load the view directly in the window then the view works as expected.... I'm not sure why it won't work with the Director's view (the cancel button in the toolbar works fine...)</p>
<p>Here's the code I use to load the view:<br />
<pre><code>[[Director sharedDirector] pause];

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:.5];
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[[Director sharedDirector] openGLView] cache:YES];

        [[[Director sharedDirector] openGLView] addSubview:controller.view];

        [UIView commitAnimations];</code></pre>
<p>But it works fine if I load it like this:</p>
<pre><code>FileViewController *file = [[FileViewController alloc] init];
        [window addSubview:file.view];
        [window makeKeyAndVisible];</code></pre></description>
		</item>
		<item>
			<title>Robert Payne on "Tip: Do not runWithScene before attachInView or attachInWindow"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/744#post-4406</link>
			<pubDate>Sat, 18 Jul 2009 22:20:54 +0000</pubDate>
			<dc:creator>Robert Payne</dc:creator>
			<guid isPermaLink="false">4406@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi All,</p>
<p>Thought I'd just share this. It isn't documented anywhere but in general avoid running a scene or allocing anything that uses OpenGL commands until the Director is attached into a window or view.</p>
<p>During the attaching process a lot of OpenGL parameters are setup and initialized. Without some of these it causes problems with gl commands. In particular if you add a texture through TextureMgr before attaching into a window/view the first texture will actually not be saved properly into the OpenGL state due to the glGetIntegerv command returning the minimum int value the first time through.</p>
<p>This could only be related to 3.1 or 3.0 but I think I've had this happen in 2.2.1 as well.
</p></description>
		</item>
		<item>
			<title>slipster216 on "iPad: Correctly scaling to 2x.."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4108#post-24621</link>
			<pubDate>Wed, 27 Jan 2010 22:01:32 +0000</pubDate>
			<dc:creator>slipster216</dc:creator>
			<guid isPermaLink="false">24621@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>When I'm working on 2d games, I prefer to work in pixel space. It's easy for me to think about things that way, as opposed to some image being 22.5% from the left of the screen. </p>
<p>With the iPad's native 1024x768 resolution, and ability to output to external monitors at potentially arbitrary sizes, we'll have to adapt the engine to properly handle native apps at multiple resolutions. </p>
<p>My suggestion is that we set a reference resolution to work in; so if you're targeting the iPad's native resolution but also want to run on the iphone, you'd do something like so:</p>
<pre><code>[[CCDirector sharedDirector] setReferenceResolution:ccp(1024, 768)];
...
[mySprite setPosition:ccp(100,100)];</code></pre>
<p>Now, if your running on the iPad the sprite is placed at 100,100. However, if your running on the iPhone, it would do the math and place the sprite at the correct position for a 320x480 resolution.</p>
<p>Sprite sheets would likely also need some concept of native resolution to do the proper scaling if we're sharing them between devices. However, I'd imagine most games would want to save the memory, and instead scale all the source images down and put them into a secondary target.
</p></description>
		</item>
		<item>
			<title>randomtruth on "How to get rid of UIKit Lag in Cocos2d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3500#post-21343</link>
			<pubDate>Sat, 19 Dec 2009 22:28:08 +0000</pubDate>
			<dc:creator>randomtruth</dc:creator>
			<guid isPermaLink="false">21343@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>When using a UIKit object you often run into one of the two problems.<br />
1. Cocos2d freezing during core-animation or UIKit Scrolling.<br />
2. Bounce and kinetic scrolling not working in UIkit Objects. </p>
<p>If you use the threaded director both problems go away,<br />
[Director setDirectorType:CCDirectorTypeThreadMainLoop]; //For replacing Fast Director<br />
[Director setDirectorType:CCDirectorTypeNSTime]; //For replacing Default Director<br />
(it has to be the first call to the director).
</p></description>
		</item>
		<item>
			<title>Yu Chao on "FPS changed a lot sometimes when pause and resume app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3361#post-20653</link>
			<pubDate>Thu, 10 Dec 2009 06:15:42 +0000</pubDate>
			<dc:creator>Yu Chao</dc:creator>
			<guid isPermaLink="false">20653@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I develop my game using cocos2d, I met issue that the fps changed a lot after I call</p>
<p><code>[[Director sharedDirector] pause];</code><br />
<code>[[Director sharedDirector] resume];</code></p>
<p>Say I started my app, the fps rate stays at 60 fps, after I click pause button twice which actually make the director paused and resumed, the fps rate may or may not changed to about 30-40. Not always but at some rate (60%?), the fps rate will jump between 60 and 30-40 when click pause and resume.</p>
<p>I don't have any clue about this, does anybody meet this?</p>
<p>Thanks in advance.
</p></description>
		</item>
		<item>
			<title>badawe on "Errors at Director Mainloop?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/3154#post-19438</link>
			<pubDate>Wed, 25 Nov 2009 12:12:22 +0000</pubDate>
			<dc:creator>badawe</dc:creator>
			<guid isPermaLink="false">19438@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Guys, i get some random errors now in my game, at the Director loop? What i'm doing wrong? Or how i can get more information, about what is crashing my app?</p>
<p><a href="http://img18.imageshack.us/i/capturadetela20091125as.png/"><img src="http://img18.imageshack.us/img18/7081/capturadetela20091125as.th.png" /></a>
</p></description>
		</item>
		<item>
			<title>sunshineDev on "Problems with setDirectorType"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2700#post-16771</link>
			<pubDate>Wed, 28 Oct 2009 19:15:01 +0000</pubDate>
			<dc:creator>sunshineDev</dc:creator>
			<guid isPermaLink="false">16771@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello again!</p>
<p>I'm taking a break from Sprites and graphics for a bit and working on the navigation of the application. And I'm having trouble with setDirectorType.</p>
<p>I'm working with a navigation bar. When I first navigate to the view that uses cocos2d it works fine, but when I go back and navigate to it again, it gives me the following error:</p>
<blockquote><p>
*** Assertion failure in +[Director setDirectorType:]<br />
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'A Director was alloced. setDirectorType must be the first call to Director'
</p></blockquote>
<p>I do all my setup regarding the Director and Sprites in the viewDidLoad method of the view controller for the view that is accessed through the navigation bar.</p>
<p>Thanks so much for your help.
</p></description>
		</item>
		<item>
			<title>SmallMike on "CADisplayLink"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1780#post-11163</link>
			<pubDate>Thu, 10 Sep 2009 04:30:34 +0000</pubDate>
			<dc:creator>SmallMike</dc:creator>
			<guid isPermaLink="false">11163@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Has anyone played with CADisplayLink in the 3.1 SDK yet? It looks like it is a "timer" that gets fired every time the screen is redrawn (or every x frames). Might be interesting to try plugging into Director in place of NSTimer. Unfortunately would only work with 3.1 devices.
</p></description>
		</item>
		<item>
			<title>brainjuice on "Director using 10-20% CPU with 1 Scene/1 Layer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2575#post-16025</link>
			<pubDate>Tue, 20 Oct 2009 16:57:11 +0000</pubDate>
			<dc:creator>brainjuice</dc:creator>
			<guid isPermaLink="false">16025@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Running in Instruments with a blank app, single scene which contains an empty layer. The app is taking between 6-7 and 20% CPU in the Activity Monitor, peaking every 5-10 seconds. </p>
<p>This doesn't sound right. Any thoughts? Or is Director just a CPU hog?
</p></description>
		</item>
		<item>
			<title>zombie on "FastDirector, why is CFRunLoopRunInMode called before AND after mainLoop?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2470#post-15436</link>
			<pubDate>Wed, 14 Oct 2009 19:50:54 +0000</pubDate>
			<dc:creator>zombie</dc:creator>
			<guid isPermaLink="false">15436@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, </p>
<p>I am experimenting with tweaking the CFRunLoopRunInMode calls in the FastDirector preMainLoop function (game must be responsive to many touches). It is not clear to me why CFRunLoopRunInMode is called twice, i.e. before and after executing the main loop. Can somebody shed some light on this? I noticed that our game runs smoother on a 3GS when commenting out the second CFRunLoopRunInMode call. </p>
<p>The code passage is pasted below. </p>
<p><code><br />
-(void) preMainLoop<br />
{<br />
	while (isRunning) {</p>
<p>		NSAutoreleasePool *loopPool = [NSAutoreleasePool new];</p>
<p>#<a href='http://www.cocos2d-iphone.org/forum/tags/if'>if</a> CC_DIRECTOR_DISPATCH_FAST_EVENTS<br />
		while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.004f, FALSE) == kCFRunLoopRunHandledSource);<br />
#else<br />
		while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);<br />
#endif</p>
<p>		if (isPaused_) {<br />
			usleep(250000); // Sleep for a quarter of a second (250,000 microseconds) so that the framerate is 4 fps.<br />
		}</p>
<p>		[self mainLoop];</p>
<p>#<a href='http://www.cocos2d-iphone.org/forum/tags/if'>if</a> CC_DIRECTOR_DISPATCH_FAST_EVENTS<br />
		while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.004f, FALSE) == kCFRunLoopRunHandledSource);<br />
#else<br />
		while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);<br />
#endif</p>
<p>		[loopPool release];<br />
	}<br />
}<br />
</code>
</p></description>
		</item>
		<item>
			<title>Finkly on "First black frame on start"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1629#post-10207</link>
			<pubDate>Tue, 01 Sep 2009 02:52:44 +0000</pubDate>
			<dc:creator>Finkly</dc:creator>
			<guid isPermaLink="false">10207@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>In my game my first scene is an exact copy of the Default.png (with the addition of a loading animation). For some while it has annoyed me that there is a perceptible flash on the transition between the two. After some debugging it seems to me that the problem comes from the Director only scheduling its mainloop and then returning from runWithScene. By the time mainloop actually runs the window has refreshed with the empty back buffer(?). At least, I know that on leaving the application delegate the Default.png is still displayed, but when the mainloop is entered for the first time the screen is blank.</p>
<p>So as an experiment I added a call to mainloop at the end of startAnimation. Sure enough the scene gets visited before returning and the black frame is no more.</p>
<p>My question is: is this safe? Everything seems to run fine and I don't see any initialization happening after the inserted call, but I haven't spent a long time looking through Director so it leaves me a little uneasy.</p>
<p>For reference, I am not using FastDirector and I am attaching to a UIWindow, not a UIView.</p>
<p>Comments?
</p></description>
		</item>
		<item>
			<title>leesti on "inconsistent fps - help!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1064#post-6374</link>
			<pubDate>Sun, 02 Aug 2009 09:40:18 +0000</pubDate>
			<dc:creator>leesti</dc:creator>
			<guid isPermaLink="false">6374@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi</p>
<p>If I build and run my app from Xcode straight to the iPhone, I get 60fps every time without fail.  If I run it directly on the iPhone (by touching my  app icon) I get slower fps (35-45).  However (and here's the strange part), if I run "Monkey Swing" - another game on my iPhone, then immediately run my game afterwards... I get 60 fps every time!!</p>
<p>Anyone seen similar behaviour before?  Any idea what could cause this?  My game is really doing nothing intensive and should easily run in 60fps.  I'm using FastDirector btw, and my game listens for touch events on a single layer.</p>
<p>Thanks - its driving me mad!
</p></description>
		</item>
		<item>
			<title>Clain on "openGLView_ is never dealloc&#039;d"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1545#post-9629</link>
			<pubDate>Thu, 27 Aug 2009 03:45:29 +0000</pubDate>
			<dc:creator>Clain</dc:creator>
			<guid isPermaLink="false">9629@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>At some point in my game, I need to remove entirely the <code>Director</code> and openGL stuff from memory. I use this :<br />
<pre><code>[[Director sharedDirector] end];
[[Director sharedDirector] release];</code></pre>
<p>By looking at the <code>CCLOG</code>s, I can see <code>Director</code> gets <code>dealloc</code>'d.</p>
<p>I've added an <code>NSLog</code> in the <code>dealloc</code> method of the <code>EAGLView</code> class and noticed it was never called. In the <code>Director</code> class, I've added <code>[openGLView_ release];</code> in the <code>dealloc</code> method because the openGL view is created with <code>alloc init</code> (bug ?). And even with this extra <code>release</code>, the EAGL view does not get <code>dealloc</code>'d.</p>
<p>This is weird because <code>Instruments</code> does not report any leak. And after I remove the <code>Director</code>, I load another openGL view (outside of cocos, and it's a modified version of the <code>EAGLView</code> class which has a different name than the <code>EAGLView</code> class provided with cocos) and it gets displayed correctly.</p>
<p>Anybody else seeing this ?
</p></description>
		</item>
		<item>
			<title>usercjp on "Problems with Director and runWithScene"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1411#post-8519</link>
			<pubDate>Tue, 18 Aug 2009 23:55:45 +0000</pubDate>
			<dc:creator>usercjp</dc:creator>
			<guid isPermaLink="false">8519@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have some code to display a logo and then immediately switch in to the main scene, but it doesn't seem to work.  Here's the code:</p>
<p>LogoView *logoLayer = [[[LogoView alloc] initWithAssets: assets] autorelease];<br />
Scene *mainScene = [[Scene node] addChild: logoLayer];<br />
[[Director sharedDirector] runWithScene: mainScene];</p>
<p>MainView *layer = [[[MainView alloc] initWithAssets: assets] autorelease];<br />
Scene *s = [[Scene node] addChild: layer];<br />
[[Director sharedDirector] replaceScene: [FadeTransition transitionWithDuration: 5.0f scene: s withColor: ccBLACK]];</p>
<p>LogoView and MainView are both subclasses of Layer.  Anyway, when I run this code, it transitions from a full black screen to Scene s.  If I comment out everything from MainView *layer down, it displays the first scene just fine, but obviously doesn't do the necessary transition.</p>
<p>What's going on here?  Is Director not full starting to run the scene before I try to replace it?  How can I fix this, if it is?
</p></description>
		</item>

	</channel>
</rss>

