<?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: AtlasSpriteManager - positioning  (noob)</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/2792</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 01:49:52 +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/2792" rel="self" type="application/rss+xml" />

		<item>
			<title>indy2005 on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17478</link>
			<pubDate>Thu, 05 Nov 2009 08:26:18 +0000</pubDate>
			<dc:creator>indy2005</dc:creator>
			<guid isPermaLink="false">17478@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Will have a look later...unfortunately work is getting between me and Cocos again....</p>
<p>i
</p></description>
		</item>
		<item>
			<title>javy on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17440</link>
			<pubDate>Thu, 05 Nov 2009 01:22:36 +0000</pubDate>
			<dc:creator>javy</dc:creator>
			<guid isPermaLink="false">17440@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>"...the sprites are actually being positioned in the Managers "parent" rather than the manager itself."</p>
<p>Are they?  It may be so, but I haven't noticed the manager working that way (I could be mistaken).</p>
<p>Try this.  Make a test app (as I often do) where you can try out things.  Add a scene with a single layer.  In the layer, add a manager and add a sprite to it.</p>
<p>From the layer, use a scheduler to move (setPosition) manager.  While moving the manager, nslog the position of the layer.  Don't forget to post the result!
</p></description>
		</item>
		<item>
			<title>indy2005 on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17437</link>
			<pubDate>Thu, 05 Nov 2009 01:13:30 +0000</pubDate>
			<dc:creator>indy2005</dc:creator>
			<guid isPermaLink="false">17437@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Thanks.  I am just trying to understand why in all the samples, the sprites are positioned within the manager, but there is never a positioning of the manager itself..</p>
<pre><code>#pragma mark Example Atlas 1

@implementation Atlas1

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

		self.isTouchEnabled = YES;

		AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@&#34;grossini_dance_atlas.png&#34; capacity:50];
		[self addChild:mgr z:0 tag:kTagSpriteManager];

		CGSize s = [[Director sharedDirector] winSize];
		[self addNewSpriteWithCoords:ccp(s.width/2, s.height/2)];

	}
	return self;
}

-(void) addNewSpriteWithCoords:(CGPoint)p
{
	AtlasSpriteManager *mgr = (AtlasSpriteManager*) [self getChildByTag:kTagSpriteManager];

	int idx = CCRANDOM_0_1() * 1400 / 100;
	int x = (idx%5) * 85;
	int y = (idx/5) * 121;

	AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
	[mgr addChild:sprite];

	sprite.position = ccp( p.x, p.y);

	id action;
	float rand = CCRANDOM_0_1();

	if( rand &#60; 0.20 )
		action = [ScaleBy actionWithDuration:3 scale:2];
	else if(rand &#60; 0.40)
		action = [RotateBy actionWithDuration:3 angle:360];
	else if( rand &#60; 0.60)
		action = [Blink actionWithDuration:1 blinks:3];
	else if( rand &#60; 0.8 )
		action = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
	else
		action = [FadeOut actionWithDuration:2];
	id action_back = [action reverse];
	id seq = [Sequence actions:action, action_back, nil];

	[sprite runAction: [RepeatForever actionWithAction:seq]];
}</code></pre>
<p>Notice the positionng of AtlasSprites, but the AtlasSpriteManager is only added with a index, and the position is never set.  This is why  thought the sprites are actually being positioned in the Managers "parent" rather than the manager itself.</p>
<p>hope the question makes sense!</p>
<p>i
</p></description>
		</item>
		<item>
			<title>javy on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17431</link>
			<pubDate>Thu, 05 Nov 2009 00:23:37 +0000</pubDate>
			<dc:creator>javy</dc:creator>
			<guid isPermaLink="false">17431@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>"... and I'd pay DOUBLE that for a good book on Cocos2d/Box2d!"</p>
<p>Make it TRIPLE if it explained the physics math in layman's terms for people like me :P</p>
<p>Indy 2005,</p>
<p>You can change the position of the sprite manager, and it will in turn change the position on all the children it contains (which can only be atlas sprites now).</p>
<p>I hardly ever use z ordering because I don't have a need for it just yet.  It allows one manager (or layer, sprite, etc) to be ordered in front or in back of another.  I usually create all my objects before displaying the scene and avoid creating new objects mid-game.  It can lead to jerky frame rates.</p>
<p>You can add nodes in the order you want them to be in.  But if you needed to create a new sprite/manager/etc mid-game you could use the z order to 'insert' a node - kind of like inserting it into an array at a specific position, and bumping the rest of the (nodes) down one.
</p></description>
		</item>
		<item>
			<title>indy2005 on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17416</link>
			<pubDate>Wed, 04 Nov 2009 22:32:54 +0000</pubDate>
			<dc:creator>indy2005</dc:creator>
			<guid isPermaLink="false">17416@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Thanks.  Where would the mystery be if it was all laid out in a book.  My mum would be writing games then ;-)</p>
<p>In all the samples I see for AtltasSpriteManager, the manager is added to the layer, and then sprites are added to the manager.  The sprites are positioned - but I never see the manager getting positioned.  I am assuming the sprites get positioned within the manager - but why does the manager never get positioned!  </p>
<p>Also, managers always seem to get added with a zindex.  If you have multiple managers in a layer with different z indexes, and different sprites in each manager with separate z-indexes....how does that work?</p>
<p>Thanks</p>
<p>i
</p></description>
		</item>
		<item>
			<title>eshirt on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17310</link>
			<pubDate>Wed, 04 Nov 2009 01:55:12 +0000</pubDate>
			<dc:creator>eshirt</dc:creator>
			<guid isPermaLink="false">17310@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>... and I'd pay DOUBLE that for a good book on Cocos2d/Box2d!  :)
</p></description>
		</item>
		<item>
			<title>javy on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17308</link>
			<pubDate>Wed, 04 Nov 2009 01:39:27 +0000</pubDate>
			<dc:creator>javy</dc:creator>
			<guid isPermaLink="false">17308@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Scene<br />
  Layers<br />
    SpriteManagers<br />
      Sprites</p>
<p>All Nodes relative to the CocosNode they were added to, and subsequently up the chain.  For example, you could change the position of a sprite, and it's manager/layer/scene would not change.</p>
<p>If, however, you moved a Layer containing a sprite, the layer and all the nodes it contains would be moved relative to how the layer moved.</p>
<p>To answer your question, moving a sprite would be moving it relative to the manager it was added to.</p>
<p>This is my understanding, anyways.</p>
<p>Oh what I would pay for a good book on Cocos2d!
</p></description>
		</item>
		<item>
			<title>indy2005 on "AtlasSpriteManager - positioning  (noob)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2792#post-17291</link>
			<pubDate>Tue, 03 Nov 2009 20:57:57 +0000</pubDate>
			<dc:creator>indy2005</dc:creator>
			<guid isPermaLink="false">17291@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Noob question.  I am working through AtlasSprites....you create a manager, add the manager to the scene or layer, and then add sprites to the manager.</p>
<p>When you are setting the position of the AtlasSprites - is the position being set relative to the layer the manager was added to - or to the manager itself (which is a subclass of CocosNode so I am guessing can have a position?)...</p>
<p>Thanks</p>
<p>i
</p></description>
		</item>

	</channel>
</rss>

