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

		<item>
			<title>GoldenJoe on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142996</link>
			<pubDate>Tue, 07 Feb 2012 07:33:12 +0000</pubDate>
			<dc:creator>GoldenJoe</dc:creator>
			<guid isPermaLink="false">142996@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Magnificent. This will make for an excellent shockwave effect.
</p></description>
		</item>
		<item>
			<title>bryce on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142876</link>
			<pubDate>Mon, 06 Feb 2012 16:33:37 +0000</pubDate>
			<dc:creator>bryce</dc:creator>
			<guid isPermaLink="false">142876@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I noticed if I try to use CCLiquid, CCWaves, etc. with this ripple effect that the ripple effect just turns black.  Is there a way to get them both to work at the same time?
</p></description>
		</item>
		<item>
			<title>ignazioc on "texture atlas and npot sprite"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28966#post-142774</link>
			<pubDate>Sun, 05 Feb 2012 20:37:56 +0000</pubDate>
			<dc:creator>ignazioc</dc:creator>
			<guid isPermaLink="false">142774@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hi, if i use a software to pack my texture in a one big texture atlas 1024x1024 can i create my single sprite in any dimension without waste memory?<br />
i know that cocos2d 1.1 use npot texture by default...this mean that my texture atlas can be 1030x1030 without problems?
</p></description>
		</item>
		<item>
			<title>Panajev on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142687</link>
			<pubDate>Sat, 04 Feb 2012 18:57:27 +0000</pubDate>
			<dc:creator>Panajev</dc:creator>
			<guid isPermaLink="false">142687@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>AFAICS, the only two shaders I saw were related to image capturing... maybe I should look at it again.</p>
<p>I am now going for a shaders based solution myself... right now testing a fragment shader solution (I have to get the center of the function moving according to the user's touch, the shader already supports changing its center, and then work on decay of the ripples as they repeat indefinitely right now), but I would like to explore your solution with a mixed CPU+VS approach (tessellate on the CPU, transform position and UV's on the GPU).</p>
<p>Another thing that I am trying to do is to make sure we can make the effect more resolution dependent: this way you can handle the fragment shader load on a low resolution buffer and then scale it up with bi-linear filtering. I am trying to think about how Cocos2D handles rendering: ideally, for this to work as easily as possible the -draw method would update a bitmap for the surface and geometric operations such as scaling, translation, and rotation were done in a separate pass starting from the surface bitmap.</p>
<p>I'll keep updating that github project to test this.</p>
<p>Hehe, cramming too many random thoughts in a single post.
</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>Birkemose on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142498</link>
			<pubDate>Fri, 03 Feb 2012 12:08:14 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142498@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/57592'>paco_777</a><br />
That demo uses ES2.0 and vertex shaders. That is SO much cheating ...
</p></description>
		</item>
		<item>
			<title>Panajev on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142483</link>
			<pubDate>Fri, 03 Feb 2012 10:26:44 +0000</pubDate>
			<dc:creator>Panajev</dc:creator>
			<guid isPermaLink="false">142483@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Performance on iPad 1 is still too low once you drag your finger around for a while. Still, this experiment allowed me to practice with quite a few things.
</p></description>
		</item>
		<item>
			<title>Paco_777 on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142405</link>
			<pubDate>Thu, 02 Feb 2012 23:19:12 +0000</pubDate>
			<dc:creator>Paco_777</dc:creator>
			<guid isPermaLink="false">142405@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,<br />
Just saw this topic.<br />
You may already know it, but there is a quite good ripple demo effect provided by Apple in their samples :<br />
<a href="http://developer.apple.com/library/ios/#samplecode/GLCameraRipple/Introduction/Intro.html" rel="nofollow">http://developer.apple.com/library/ios/#samplecode/GLCameraRipple/Introduction/Intro.html</a></p>
<p>I don't know how easy this could be integrated with Cocos2D.<br />
I also don't know how good your results are compared to this demo, but, in case you're not aware of that demo, you should have a look at it, since it might contain some interesting info.
</p></description>
		</item>
		<item>
			<title>Birkemose on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142376</link>
			<pubDate>Thu, 02 Feb 2012 19:53:13 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142376@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/7756'>Panajev</a><br />
Cool of you to add on this. I really haven't got friendly with github yet, so I have a hard time following.</p>
<p>As for the updates. I use the final rippleSprite for two projects I am currently working on, so classes tend to be specific at this point.<br />
What saved me the most time in my final classes is:<br />
1)<br />
Only scan inside ripple area. I calculate a simple box based on current ripple radius, and only scan that. Saved a lot of calculations, especially when the ripples are "young"<br />
2)<br />
Since I only simulate water, and the center in water simulation settles fast, I also do not scan ripples below a certain radius threshold. While it saves less calculations, it especially adds up on "older" ripples. ( good combination with saving on young ripples )<br />
3)<br />
I count ongoing calculations ( ripple vertices modified ), and based on hardware ( 4999 calculations on a 3G ), I remove oldest ripples. On an iP4 ( double tesselation due to HD ) and max 19999 calculations, it is almost unnoticeable.<br />
4)<br />
Texture correction is dropped above a certain radius, and only vertex lighting is done. The distortion is so subtle at this point, that vertex lighting makes a better result at higher radius. Vertex lighting at lower radius is darkened, because that makes twirls look more impressive. At hight radius vertex lighting is lightened because it makes it look more like caustics on the background. </p>
<p>The caustics is made like HalfLife, by scanning two patterns in opposite Y direction. I added a modulation in X direction, to make it more subtle and less repeatable.</p>
<p>I hope this made sense ...
</p></description>
		</item>
		<item>
			<title>Panajev on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142295</link>
			<pubDate>Thu, 02 Feb 2012 11:25:21 +0000</pubDate>
			<dc:creator>Panajev</dc:creator>
			<guid isPermaLink="false">142295@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Added a small README and made a pull request (one can try ;)). One of the other changes is that the compiler being targeted now is the latest Clang release. Tested with iOS 5.1 Beta 3 on the simulator and on the iPad 1 on which it is a bit slow when played full-screen, but not too slow. Load must be reduced further because the touches are lagging behind a bit too much right now (if you move the finger fast across the screen).</p>
<p>Edit: iPad is full screen and Retina should work too... brute force scale to create the hd and ipad images and adjustments wherever I saw iPhone's resolution being targeted.
</p></description>
		</item>
		<item>
			<title>sefiroths on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142294</link>
			<pubDate>Thu, 02 Feb 2012 11:24:08 +0000</pubDate>
			<dc:creator>sefiroths</dc:creator>
			<guid isPermaLink="false">142294@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>wow it's really cool seeing professionals talking and sharing their solutions!
</p></description>
		</item>
		<item>
			<title>Panajev on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142291</link>
			<pubDate>Thu, 02 Feb 2012 10:53:04 +0000</pubDate>
			<dc:creator>Panajev</dc:creator>
			<guid isPermaLink="false">142291@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p><a href="https://github.com/Panajev/rippleDemo" rel="nofollow">https://github.com/Panajev/rippleDemo</a></p>
<p>Here it is, a very quick conversion.<br />
I'll toy with shaders next although I do believe that it might be cheaper with vertex trickery on iPad 1 than moving to a full shaders based solution on such a constrained device (pixel processing power:resolution wise).
</p></description>
		</item>
		<item>
			<title>Panajev on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142276</link>
			<pubDate>Thu, 02 Feb 2012 09:53:47 +0000</pubDate>
			<dc:creator>Panajev</dc:creator>
			<guid isPermaLink="false">142276@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I think that it would be useful to render to a low resolution texture and upscale it with bi-linear filtering active. I have used it with the old CCGrid3D ripple effects and it looks quite good(1/4 resolution CCRenderTexture). I'll practice with your code by forking it and doing the least it has to be done to convert it to OpenGL ES 2.0 and Cocos2D 2.0.
</p></description>
		</item>
		<item>
			<title>Birkemose on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142264</link>
			<pubDate>Thu, 02 Feb 2012 08:04:50 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142264@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@pOoOq<br />
The rippleSprite renders a texture to a rectangle you define. This is done "manually", ie using OpenGL directly.<br />
So in order to render anything which will be affected by the ripples, you need to include it in the texture you provide for rippleSprite.<br />
The easiest way, is to grab the texture from a CCRenderTexture. You then render your stuff to the CCRenderTexture, and in the draw method of rippleSprite, you then simply bind the texture of the CCRenderNode.<br />
So the changes to rippleSprite only includes maintaining a pointer to the CCTexture2D of the CCRenderTexture, and bind this when drawing.<br />
<pre><code>@property ( retain ) CCTexture2D* texture; 

@synthesize texture;

glBindTexture( GL_TEXTURE_2D, [ texture name ] );</code></pre></description>
		</item>
		<item>
			<title>p0o0q on "[code] Water ripples"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25090/page/2#post-142259</link>
			<pubDate>Thu, 02 Feb 2012 07:11:47 +0000</pubDate>
			<dc:creator>p0o0q</dc:creator>
			<guid isPermaLink="false">142259@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Excellent !</p>
<p>Would you please explain more how to add CCLabel/CCSprite (runtime update) underneath the ripple effect? Thanks.</p>
<p>Regards,<br />
p0o0q
</p></description>
		</item>
		<item>
			<title>CAppleton on "Animation sprites not showing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28802#post-141914</link>
			<pubDate>Mon, 30 Jan 2012 22:53:57 +0000</pubDate>
			<dc:creator>CAppleton</dc:creator>
			<guid isPermaLink="false">141914@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everyone, I apologise if this sort of thread has been posted and discussed but i could not see it when i looked, I am pretty new to cocos2d and this is the first time I have done any animations on it. I have created a valid plise and png with the same file name and added them to my project, i then have the following code in my class to setup the animation of the sprite in it:</p>
<p>CCSpriteFrameCache* framecache = [CCSpriteFrameCache sharedSpriteFrameCache];</p>
<p>        CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"SnakeAnimation.png"];<br />
        [m_gameScene addChild:spriteSheet];</p>
<p>        [framecache addSpriteFramesWithFile:@"SnakeAnimation.plist"];</p>
<p>        m_sprite = [CCSprite spriteWithSpriteFrameName:@"Snake2.png"];<br />
        [spriteSheet addChild:m_sprite];</p>
<p>        NSMutableArray* animFrames = [NSMutableArray array];<br />
        for(int i = 0; i &#60; 7; i++)<br />
        {<br />
            CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Snake%d.png",i+1]];<br />
            [animFrames addObject:frame];<br />
        }</p>
<p>        CCAnimation *animation = [CCAnimation animationWithFrames:animFrames delay:0.1];</p>
<p>        [m_sprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:animation] ]];</p>
<p>I have checked the frame cache etc and they are all valid and appear to add the plist etc correctly, however they can never find any of the files and my objects are created on screen without any image what so ever. I'm not sure what else i need to do to get it working so any help would be greatly appreciated!
</p></description>
		</item>
		<item>
			<title>elsevero on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141833</link>
			<pubDate>Mon, 30 Jan 2012 09:00:15 +0000</pubDate>
			<dc:creator>elsevero</dc:creator>
			<guid isPermaLink="false">141833@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/57693'>breskit</a>: I've replaced with CCCallFuncN and doesn't work...</p>
<p>@<a href='http://www.cocos2d-iphone.org/forum/profile/20192'>Birkemose</a>: Tried your code but it doesn't work either, maybe I'm not use it correctly; Can you explain? Thanks!</p>
<p>Would look like this?</p>
<pre><code>for ( int index = selectedSpritesArray.count - 1; index &#62;= 0; index -- ) {
        selectedSprite = [ selectedSpritesArray objectAtIndex:index ];
        if (CGRectContainsPoint(selectedSprite.boundingBox, touchLocation) ) {
            [selectedSpritesArray removeObjectAtIndex: index ];
        newSprite = selectedSprite;
        break;
        }
    }</code></pre></description>
		</item>
		<item>
			<title>KORNMIRZA on "how to use ccfollow and keep the sprite left side?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28778#post-141813</link>
			<pubDate>Mon, 30 Jan 2012 04:03:07 +0000</pubDate>
			<dc:creator>KORNMIRZA</dc:creator>
			<guid isPermaLink="false">141813@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>thank you winzz it works fine
</p></description>
		</item>
		<item>
			<title>winzz on "how to use ccfollow and keep the sprite left side?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28778#post-141808</link>
			<pubDate>Mon, 30 Jan 2012 03:07:50 +0000</pubDate>
			<dc:creator>winzz</dc:creator>
			<guid isPermaLink="false">141808@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>create CCNode in the middle of the screen that move along the sprite on the left side.<br />
then use CCFollow with that CCNode
</p></description>
		</item>
		<item>
			<title>Harrison Xi on "How to create white flash effect for sprites?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28478#post-141805</link>
			<pubDate>Mon, 30 Jan 2012 02:39:07 +0000</pubDate>
			<dc:creator>Harrison Xi</dc:creator>
			<guid isPermaLink="false">141805@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks for all your help. :)</p>
<p>@<a href='http://www.cocos2d-iphone.org/forum/profile/57377'>JC</a>, I did not understand your meaning at first. Now I think it must work. Thanks a lot.
</p></description>
		</item>
		<item>
			<title>KORNMIRZA on "how to use ccfollow and keep the sprite left side?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28778#post-141802</link>
			<pubDate>Mon, 30 Jan 2012 01:42:55 +0000</pubDate>
			<dc:creator>KORNMIRZA</dc:creator>
			<guid isPermaLink="false">141802@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Heloo<br />
as you know ccfollow is moving the sprite to the center of the screen,i want to find a way to hold my sprite in it's position that is left side.<br />
can anyone help me?<br />
thank you in advance
</p></description>
		</item>
		<item>
			<title>Birkemose on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141541</link>
			<pubDate>Fri, 27 Jan 2012 15:26:23 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">141541@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/70744'>elsevero</a><br />
No. I dont think it is allowed to modify arrays, using that syntax. Do it the old fashioned way.<br />
<pre><code>for ( int index = selectedSpritesArray.count - 1; index &#62;= 0; index -- ) {
  selectedSprite = [ selectedSpritesArray objectAtIndex:index ];
  if ( ... ) [ selectedSpriteArray removeObjectAtIndex: index ];
}</code></pre></description>
		</item>
		<item>
			<title>elsevero on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141534</link>
			<pubDate>Fri, 27 Jan 2012 14:27:38 +0000</pubDate>
			<dc:creator>elsevero</dc:creator>
			<guid isPermaLink="false">141534@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/57693'>breskit</a>: Thanks! I'll try that, and let you know the results :)</p>
<p>@<a href='http://www.cocos2d-iphone.org/forum/profile/32858'>phantomsri</a>: Thank you for the code! I'm using Ray's tutorial with dragging sprites to the screen but I don't think will be useful for me...<br />
I'm saying that because I have objects that are placed to the exact position (lets say: box.png sprite must be always to ccp(128,128) and if I'm trying to touch the sprite object by tag I have a issue and that is always I'll be able to touch the box.png object around the position 128(x), 128(y)<br />
I'm using a parallaxNode to scroll my two CCLayers in which I've added the sprite objects. </p>
<p>Another reason for adding the objects to array and remove them is to track them. I'll have to know if the player removed 4 specific sprites to display a message or do something else..</p>
<p>If there's any other possibility, I'd love to know it! </p>
<p>@<a href='http://www.cocos2d-iphone.org/forum/profile/20192'>Birkemose</a>: Thanks! You mean:</p>
<p><code>for (CCSprite *sprite in [selectedSpritesArray reverseObjectEnumerator])</code> ?
</p></description>
		</item>
		<item>
			<title>Birkemose on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141520</link>
			<pubDate>Fri, 27 Jan 2012 12:48:26 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">141520@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You can not iterate forward through an array, removing array members on the fly. It simply does not work.<br />
You have to iterate backwards.
</p></description>
		</item>
		<item>
			<title>phantomsri on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141518</link>
			<pubDate>Fri, 27 Jan 2012 12:41:47 +0000</pubDate>
			<dc:creator>phantomsri</dc:creator>
			<guid isPermaLink="false">141518@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hi @<a href='http://www.cocos2d-iphone.org/forum/profile/70744'>elsevero</a> first of all, all the sprites i used comes with a tag.</p>
<p>I used the tag to remove the sprite. I had tagged it from Number 1 to 3. The code i posted in my tread comes with a loop, each time the user touches the overlapped sprite, the code will check is the sprite tag is number 1 to 3, if its the correct tag it will remove it .</p>
<p>Try this if you are using the code from <a href="http://www.raywenderlich.com/" rel="nofollow">http://www.raywenderlich.com/</a></p>
<pre><code>movableSprites = [[NSMutableArray alloc] init];
        NSArray *images = [NSArray arrayWithObjects:@&#34;bird.png&#34;, @&#34;cat.png&#34;, @&#34;dog.png&#34;, @&#34;turtle.png&#34;, nil];
        for(int i = 0; i &#60; images.count; ++i) {
            NSString *image = [images objectAtIndex:i];
            CCSprite *sprite = [CCSprite spriteWithFile:image];
            float offsetFraction = ((float)(i+1))/(images.count+1);
            sprite.position = ccp(winSize.width*offsetFraction, winSize.height/2);
            [self addChild:sprite z:1 tag:i]; // the tag i based on image count 1 to 4, so the tag will start from 1 to 4
            [movableSprites addObject:sprite];</code></pre>
<p>try this touch code<br />
<pre><code>-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch* myTouch = [touches anyObject];
    CGPoint location = [myTouch locationInView: [myTouch view]];
    location = [[CCDirector sharedDirector]convertToGL:location];
    location = [self convertToNodeSpace:location];

    int totalNumberOfItems=5;
    for (int y=0; y &#60; totalNumberOfItems; y++){
        CCSprite *temp = (CCSprite*)[self getChildByTag:y];

        CGRect test1 = [temp boundingBox];

        if (CGRectContainsPoint(test1, location)) {

            [self removeChild:temp cleanup:YES ];
            // i have removed &#34;return;&#34;
        }
    }  

}</code></pre></description>
		</item>
		<item>
			<title>breskit on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141501</link>
			<pubDate>Fri, 27 Jan 2012 09:47:01 +0000</pubDate>
			<dc:creator>breskit</dc:creator>
			<guid isPermaLink="false">141501@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Replace the CCCallFunc with CCCallFuncN.  This was you pass a reference to the object you are working on.
</p></description>
		</item>
		<item>
			<title>elsevero on "how to remove a overlapped sprite."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28537#post-141494</link>
			<pubDate>Fri, 27 Jan 2012 08:42:32 +0000</pubDate>
			<dc:creator>elsevero</dc:creator>
			<guid isPermaLink="false">141494@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/32858'>phantomsri</a>: How did you manage to remove overlapped sprites?</p>
<p>I was thinking to use Ray's tutorial example (<a href="http://www.raywenderlich.com/2343/how-to-drag-and-drop-sprites-with-cocos2d" rel="nofollow">http://www.raywenderlich.com/2343/how-to-drag-and-drop-sprites-with-cocos2d</a>) and adjust it, but I have some issues with the overlapped sprites; The issue is that I can't remove the objects that are place below the first sprite.</p>
<p>Here's the code which I'm using right now (I'm using some animation but I don't think that causes that):</p>
<pre><code>- (void)selectSpriteForTouch:(CGPoint)touchLocation {
    CCSprite * newSprite = nil;
    for (CCSprite *sprite in selectedSpritesArray) {
        if (CGRectContainsPoint(sprite.boundingBox, touchLocation)) {
            newSprite = sprite;
            break;
        }
    }

    if (newSprite) {
        CCSprite *fixedSprite = [CCSprite spriteWithSpriteFrameName:@&#34;Animation_01.png&#34;];

        fixedSprite.position = ccp(newSprite.contentSize.width/2,newSprite.contentSize.height/2);
        [newSprite addChild:fixedSprite];

        NSMutableArray *animFrames = [NSMutableArray array];
        for(int i = 1; i &#60;= 10; ++i) {

            [animFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@&#34;Animation_%02d.png&#34;, i]]];
        }

        CCAnimation *anim = [CCAnimation animationWithFrames:animFrames delay:0.05f];
        CCActionInterval *animAction = [CCAnimate actionWithAnimation:anim restoreOriginalFrame:NO];

        id seq = [CCSequence actions: animAction, [CCCallFunc actionWithTarget:fixedSprite selector:@selector(removeFromParentAndCleanup:)], [CCCallFunc actionWithTarget:newSprite selector:@selector(removeFromParentAndCleanup:)], nil];
        [fixedSprite runAction:seq];
    }
}

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
    CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
    [self selectSpriteForTouch:touchLocation];
    return TRUE;
}</code></pre>
<p>If anyone knows, please guide me; thanks!
</p></description>
		</item>
		<item>
			<title>eJayStudios on "Smooth moving sprite with accelerometer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28679#post-141318</link>
			<pubDate>Thu, 26 Jan 2012 05:44:39 +0000</pubDate>
			<dc:creator>eJayStudios</dc:creator>
			<guid isPermaLink="false">141318@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Looked trough many threads, can't find a solution.<br />
I've implemented accelerometer ala "Tilt to Live",  from <a href="http://www.paradeofrain.com/2010/07/lessons-learned-in-tilt-controls/">here</a></p>
<p>Accelerometer code works very nice, no issue here. But there is 2 strange things:</p>
<p>- first, I downloaded example from link above and little image moves much faster in example project with same settings compared to my project (example project in in OpenGL)<br />
- second, in my game when sprite moves I can see a little trail behind image as if it doesn't refresh nicely, sort of flickering effect.</p>
<p>Basically code is this:</p>
<pre><code>- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
    Vec2 accel2D(0,0);
    Vec3 ax(1, 0, 0);
    Vec3 ay(-.63f, 0,-.92f);
    Vec3 az(Vec3::Cross(ay,ax).normalize());
    ax = Vec3::Cross(az,ay).normalize();
    accel2D.x = -Vec3::Dot(Vec3(acceleration.x, acceleration.y, acceleration.z), ax);
    accel2D.y = -Vec3::Dot(Vec3(acceleration.x, acceleration.y, acceleration.z), az);

    const float xSensitivity = 2.8f;
    const float ySensitivity = 2.8f; // yay magic numbers!
    const float tiltAmplifier = 8; // w0ot more magic numbers

    // since we are in a landscape orientation.
    // now apply it to our player&#039;s velocity data.
    // we also rotate the 2D vector by 90 degrees by switching the components and negating one
    vx += -(accel2D.y) * tiltAmplifier * xSensitivity;
    vy += -accel2D.x * tiltAmplifier * ySensitivity;
}</code></pre>
<p>Then in update I do this:</p>
<pre><code>-(void) update:(ccTime)delta
{
	x += vx;
	y += vy;

	// put the breaks on our velocity.
	vx *= 0.2f;
	vy *= 0.2f;

	//bound the player
	if (x &#62; 460)
	{
		x = 460;
	}
	if( x &#60; 20)
	{
		x = 20;
	}

	if(y &#62; 300)
	{
		y = 300;
	}
	if( y &#60; 20)
	{
		y = 20;
	}

    playerSprite.position = ccp(x, y);
}</code></pre>
<p>Tried with setting animation refresh to 1/30, also accelerometer update interval to 1/30, nothing helps.<br />
If I increase sensitivity via xSensitivity, ySensitivity I can get sprite to move as fast as in example project, but flickering effect is even worse.</p>
<p>Any idea what I'm doing wrong? Why image in my game runs much slower then in example with same settings? Could it be because in cocos2D we have update method?
</p></description>
		</item>
		<item>
			<title>bryce on "change one sprite to another"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/11920#post-141154</link>
			<pubDate>Wed, 25 Jan 2012 14:08:40 +0000</pubDate>
			<dc:creator>bryce</dc:creator>
			<guid isPermaLink="false">141154@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>If you're using sprite frame cache you could do something like:<br />
<pre><code>CCSpriteFrame *frame;
frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@&#34;first.png&#34;];
[self setDisplayFrame:frame];

frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@&#34;second.png&#34;];
[self setDisplayFrame:frame];</code></pre></description>
		</item>
		<item>
			<title>RishabhShah on "change one sprite to another"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/11920#post-141111</link>
			<pubDate>Wed, 25 Jan 2012 06:27:32 +0000</pubDate>
			<dc:creator>RishabhShah</dc:creator>
			<guid isPermaLink="false">141111@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>How to add animation when the sprite are replacing?
</p></description>
		</item>

	</channel>
</rss>

