<?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; Topic: Any way to add Rects to a CCAnimation without texture?</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/4285</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:09:44 +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/topic/4285" rel="self" type="application/rss+xml" />

		<item>
			<title>Metric on "Any way to add Rects to a CCAnimation without texture?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4285#post-25998</link>
			<pubDate>Mon, 08 Feb 2010 20:26:29 +0000</pubDate>
			<dc:creator>Metric</dc:creator>
			<guid isPermaLink="false">25998@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Could you just not add a parameter to the singleton function that references a texture2d?</p>
<p>For example:</p>
<pre><code>//Declare a texture 2d / CCSpriteSheet
CCSpriteSheet * sheet = [CCSpriteSheet spriteSheetWithFile:@&#34;file.png&#34;];

//Pass the texture of the spritesheet to your singleton function
CustomAnimateObject * anim1 = [singleton createAnimation:sheet.texture];

//The CustomAnimateObject would have the following properties
CCAnimation * animation;
CCAction * animationAction;

//Would have the following init function:
-(id) initWithAnimation:(CCAnimation *) animation1 action:(CCAction *) animationAction1;

//Singleton function would then do the following instead:
CCAnimation * anim1;
CCAction *action1;

anim1 = [CCAnimation animationWithName:@&#34;whatever&#34; delay:0.1f];
for(int i=0;i&#60;9;i++)
{
  [anim1 addFrameWithTexture:animationTexture rect: CGRectMake(i*64, 0,64, 128)];
}
action1 =[Animate actionWithAnimation:anim1 restoreOriginalFrame:NO];
//Depending on if the CustomAnimationObject is just NSObject or uses a CCNode the allocing will be different or the same
CustomAnimationObject *CAO = [[CustomAnimationObject node] initWithAnimation:anim1 action: action1];

//Then in your CustomAnimationObject you would then retain the 2 objects passed to it in the init function
//Finally we return the new CustomAnimationObject
return CAO;</code></pre>
<p>Please note all is pseudo code and may need adjusting according to your needs.
</p></description>
		</item>
		<item>
			<title>Smauky on "Any way to add Rects to a CCAnimation without texture?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4285#post-25980</link>
			<pubDate>Mon, 08 Feb 2010 17:06:53 +0000</pubDate>
			<dc:creator>Smauky</dc:creator>
			<guid isPermaLink="false">25980@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>no one knows any way?</p>
<p>please i really need it
</p></description>
		</item>
		<item>
			<title>Smauky on "Any way to add Rects to a CCAnimation without texture?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/4285#post-25627</link>
			<pubDate>Fri, 05 Feb 2010 21:05:35 +0000</pubDate>
			<dc:creator>Smauky</dc:creator>
			<guid isPermaLink="false">25627@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Im trying to migrate from 0.8.2 to 0.99, i think all its done but the CCAnimation migration.</p>
<p>I have a singleton class that keeps some CCAnimations that can be shared with diferents CCSpriteSheets, for example, i have 3 CCSpriteSheets, with diferent textures but same number of frames, and same size, i usually create a CCAction with the animation of that CCSprites, something like this:</p>
<p>[code]<br />
static CCAnimation *aniZ1Morir;<br />
static CCAction *accZ1Morir;</p>
<p>aniZ1Morir = [[CCAnimation animationWithName:@"aniZ1Morir" delay:0.1f] retain];<br />
	for(int i=0;i&#60;9;i++) {<br />
		[aniZ1Morir addFrameWithRect: CGRectMake(i*64, 0, 64, 128) ];<br />
	}<br />
accZ1Morir = [[Animate actionWithAnimation:aniZ1Morir restoreOriginalFrame:NO] retain];<br />
[/code]</p>
<p>Then when any of the CCSprites that use any of the 3 CCSpriteSheets, need to use the animate, i just run a copy of that "accZ1Morir" CCAction, and of course its compatible.</p>
<p>But now, with the new CCAnimation, i must pass a Texture2D when creating the frames, theres any way to dont need that texture? so i can continue use that singleton class?</p>
<p>This its only an example, but i have more than 50 similar actions, used with arround 100 diferent animations, so migrating can be a really time consuming task if i need to change them all
</p></description>
		</item>

	</channel>
</rss>

