本文整理汇总了C#中cocos2d.CCSprite.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.AddChild方法的具体用法?C# CCSprite.AddChild怎么用?C# CCSprite.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCSprite
的用法示例。
在下文中一共展示了CCSprite.AddChild方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpriteBatchNodeChildren
public SpriteBatchNodeChildren()
{
CCSize s = CCDirector.SharedDirector.WinSize;
// parents
CCSpriteBatchNode batch = CCSpriteBatchNode.Create("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
CCSprite sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2));
CCSprite sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(50, 50));
CCSprite sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-50, -50));
batch.AddChild(sprite1);
sprite1.AddChild(sprite2);
sprite1.AddChild(sprite3);
// BEGIN NEW CODE
var animFrames = new List<CCSpriteFrame>();
string str = "";
for (int i = 1; i < 15; i++)
{
string temp = "";
if (i<10)
{
temp = "0" + i;
}
else
{
temp = i.ToString();
}
str = string.Format("grossini_dance_{0}.png", temp);
CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
animFrames.Add(frame);
}
CCAnimation animation = CCAnimation.Create(animFrames, 0.2f);
sprite1.RunAction(new CCRepeatForever (new CCAnimate (animation)));
// END NEW CODE
CCActionInterval action = new CCMoveBy (2, new CCPoint(200, 0));
CCActionInterval action_back = (CCActionInterval)action.Reverse();
CCActionInterval action_rot = new CCRotateBy (2, 360);
CCActionInterval action_s = new CCScaleBy(2, 2);
CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse();
CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse();
sprite2.RunAction(new CCRepeatForever (seq2));
sprite1.RunAction((CCAction)(new CCRepeatForever (action_rot)));
sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action, action_back)))));
sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action_s, action_s_back)))));
}
示例2: SpriteBatchNodeReorderIssue767
public SpriteBatchNodeReorderIssue767()
{
CCSize s = CCDirector.SharedDirector.WinSize;
string scope = CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist", "animations/ghosts");
CCNode aParent;
CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;
//
// SpriteBatchNode: 3 levels of children
//
aParent = new CCSpriteBatchNode("animations/ghosts");
AddChild(aParent, 0, (int) kTagSprite.kTagSprite1);
// parent
l1 = new CCSprite(scope + "father.gif");
l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
aParent.AddChild(l1, 0, (int) kTagSprite.kTagSprite2);
CCSize l1Size = l1.ContentSize;
// child left
l2a = new CCSprite(scope + "sister1.gif");
l2a.Position = (new CCPoint(-25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
l1.AddChild(l2a, -1, (int) kTags.kTagSpriteLeft);
CCSize l2aSize = l2a.ContentSize;
// child right
l2b = new CCSprite(scope + "sister2.gif");
l2b.Position = (new CCPoint(+25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
l1.AddChild(l2b, 1, (int) kTags.kTagSpriteRight);
CCSize l2bSize = l2a.ContentSize;
// child left bottom
l3a1 = new CCSprite(scope + "child1.gif");
l3a1.Scale = (0.65f);
l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, -50 + l2aSize.Height / 2));
l2a.AddChild(l3a1, -1);
// child left top
l3a2 = new CCSprite(scope + "child1.gif");
l3a2.Scale = (0.65f);
l3a2.Position = (new CCPoint(0 + l2aSize.Width / 2, +50 + l2aSize.Height / 2));
l2a.AddChild(l3a2, 1);
// child right bottom
l3b1 = new CCSprite(scope + "child1.gif");
l3b1.Scale = (0.65f);
l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -50 + l2bSize.Height / 2));
l2b.AddChild(l3b1, -1);
// child right top
l3b2 = new CCSprite(scope + "child1.gif");
l3b2.Scale = (0.65f);
l3b2.Position = (new CCPoint(0 + l2bSize.Width / 2, +50 + l2bSize.Height / 2));
l2b.AddChild(l3b2, 1);
Schedule(reorderSprites, 1);
}
示例3: SpriteChildrenVisibilityIssue665
public SpriteChildrenVisibilityIssue665()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
CCNode aParent;
CCSprite sprite1, sprite2, sprite3;
//
// SpriteBatchNode
//
// parents
aParent = new CCSpriteBatchNode("animations/grossini", 50);
aParent.Position = (new CCPoint(s.Width / 3, s.Height / 2));
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
//
// Sprite
//
aParent = new CCNode ();
aParent.Position = (new CCPoint(2 * s.Width / 3, s.Height / 2));
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
}
示例4: OnEnter
public override void OnEnter()
{
base.OnEnter();
float x, y;
CCSize size = CCDirector.SharedDirector.WinSize;
x = size.Width;
y = size.Height;
CCSprite bg = new CCSprite("Images/background3");
AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
bg.Position = new CCPoint(x / 2, y / 2);
grossini = new CCSprite("Images/grossinis_sister2");
bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
grossini.Position = new CCPoint(x / 3.0f, 200);
CCActionInterval sc = new CCScaleBy(2, 5);
CCFiniteTimeAction sc_back = sc.Reverse();
grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));
tamara = new CCSprite("Images/grossinis_sister1");
bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
tamara.Position = new CCPoint(2 * x / 3.0f, 200);
CCActionInterval sc2 = new CCScaleBy(2, 5);
CCFiniteTimeAction sc2_back = sc2.Reverse();
tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));
CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);
label.Position = new CCPoint(x / 2, y - 80);
AddChild(label);
label.Tag = EffectAdvanceScene.kTagLabel;
string strSubtitle = subtitle();
if (strSubtitle != null)
{
CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16);
AddChild(l, 101);
l.Position = new CCPoint(size.Width / 2, size.Height - 80);
}
CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
CCMenu menu = CCMenu.Create(item1, item2, item3);
menu.Position = new CCPoint(0, 0);
item1.Position = new CCPoint(size.Width / 2 - 100, 30);
item2.Position = new CCPoint(size.Width / 2, 30);
item3.Position = new CCPoint(size.Width / 2 + 100, 30);
AddChild(menu, 1);
}
示例5: makeSpriteZ
public CCSprite makeSpriteZ(int aZ)
{
CCSprite sprite = new CCSprite(batchNode.Texture, new CCRect(128, 0, 64, 64));
batchNode.AddChild(sprite, aZ + 1, 0);
//children
CCSprite spriteShadow = new CCSprite(batchNode.Texture, new CCRect(0, 0, 64, 64));
spriteShadow.Opacity = 128;
sprite.AddChild(spriteShadow, aZ, 3);
CCSprite spriteTop = new CCSprite(batchNode.Texture, new CCRect(64, 0, 64, 64));
sprite.AddChild(spriteTop, aZ + 2, 3);
return sprite;
}
示例6: NodeToWorld
public NodeToWorld()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
CCSprite back = new CCSprite(TestResource.s_back3);
AddChild(back, -10);
back.AnchorPoint = (new CCPoint(0, 0));
CCSize backSize = back.ContentSize;
CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
CCMenu menu = new CCMenu(item);
menu.AlignItemsVertically();
menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
back.AddChild(menu);
CCActionInterval rot = new CCRotateBy (5, 360);
CCAction fe = new CCRepeatForever (rot);
item.RunAction(fe);
CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0));
var move_back = (CCActionInterval) move.Reverse();
CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq);
back.RunAction(fe2);
}
示例7: Test6
public Test6()
{
CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);
sp1.Position = (new CCPoint(100, 160));
sp2.Position = (new CCPoint(380, 160));
CCActionInterval rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse() as CCActionInterval;
CCAction forever1 = new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(rot, rot_back));
var forever11 = (CCAction) (forever1.Copy());
var forever2 = (CCAction) (forever1.Copy());
var forever21 = (CCAction) (forever1.Copy());
AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
sp1.AddChild(sp11);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
sp2.AddChild(sp21);
sp1.RunAction(forever1);
sp11.RunAction(forever11);
sp2.RunAction(forever2);
sp21.RunAction(forever21);
Schedule(addAndRemove, 2.0f);
}
示例8: CameraOrbitTest
public CameraOrbitTest()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite p = new CCSprite(TestResource.s_back3);
AddChild(p, 0);
p.Position = (new CCPoint(s.Width / 2, s.Height / 2));
p.Opacity = 128;
CCSprite sprite;
CCOrbitCamera orbit;
CCCamera cam;
CCSize ss;
// LEFT
s = p.ContentSize;
sprite = new CCSprite(TestResource.s_pPathGrossini);
sprite.Scale = (0.5f);
p.AddChild(sprite, 0);
sprite.Position = (new CCPoint(s.Width / 4 * 1, s.Height / 2));
cam = sprite.Camera;
orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 0, 0);
sprite.RunAction(new CCRepeatForever (orbit));
// CENTER
sprite = new CCSprite(TestResource.s_pPathGrossini);
sprite.Scale = 1.0f;
p.AddChild(sprite, 0);
sprite.Position = new CCPoint(s.Width / 4 * 2, s.Height / 2);
orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 45, 0);
sprite.RunAction(new CCRepeatForever (orbit));
// RIGHT
sprite = new CCSprite(TestResource.s_pPathGrossini);
sprite.Scale = 2.0f;
p.AddChild(sprite, 0);
sprite.Position = new CCPoint(s.Width / 4 * 3, s.Height / 2);
ss = sprite.ContentSize;
orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 90, -45);
sprite.RunAction(new CCRepeatForever (orbit));
// PARENT
orbit = new CCOrbitCamera(10, 1, 0, 0, 360, 0, 90);
p.RunAction(new CCRepeatForever (orbit));
Scale = 1;
}
示例9: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1);
CCSprite sp4 = new CCSprite(TestResource.s_pPathSister2);
sp1.Position = (new CCPoint(100, s.Height / 2));
sp2.Position = (new CCPoint(380, s.Height / 2));
AddChild(sp1);
AddChild(sp2);
sp3.Scale = (0.25f);
sp4.Scale = (0.25f);
sp1.AddChild(sp3);
sp2.AddChild(sp4);
CCActionInterval a1 = new CCRotateBy (2, 360);
CCActionInterval a2 = new CCScaleBy(2, 2);
CCAction action1 = new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(a1, a2, a2.Reverse())
);
CCAction action2 = new CCRepeatForever ((CCActionInterval)
(CCSequence.FromActions(
(CCActionInterval) (a1.Copy()),
(CCActionInterval) (a2.Copy()),
a2.Reverse()))
);
sp2.AnchorPoint = (new CCPoint(0, 0));
sp1.RunAction(action1);
sp2.RunAction(action2);
}
示例10: SpriteBatchNodeChildrenScale
public SpriteBatchNodeChildrenScale()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini_family.plist");
CCNode aParent;
CCSprite sprite1, sprite2;
CCActionInterval rot = new CCRotateBy (10, 360);
CCAction seq = new CCRepeatForever (rot);
//
// Children + Scale using Sprite
// Test 1
//
aParent = new CCNode ();
sprite1 = new CCSprite("grossinis_sister1.png");
sprite1.Position = new CCPoint(s.Width / 4, s.Height / 4);
sprite1.ScaleX = -0.5f;
sprite1.ScaleY = 2.0f;
sprite1.RunAction(seq);
sprite2 = new CCSprite("grossinis_sister2.png");
sprite2.Position = (new CCPoint(50, 0));
AddChild(aParent);
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2);
//
// Children + Scale using SpriteBatchNode
// Test 2
//
aParent = new CCSpriteBatchNode("animations/grossini_family");
sprite1 = new CCSprite("grossinis_sister1.png");
sprite1.Position = new CCPoint(3 * s.Width / 4, s.Height / 4);
sprite1.ScaleX = -0.5f;
sprite1.ScaleY = 2.0f;
sprite1.RunAction((CCAction)(seq.Copy()));
sprite2 = new CCSprite("grossinis_sister2.png");
sprite2.Position = (new CCPoint(50, 0));
AddChild(aParent);
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2);
//
// Children + Scale using Sprite
// Test 3
//
aParent = new CCNode ();
sprite1 = new CCSprite("grossinis_sister1.png");
sprite1.Position = (new CCPoint(s.Width / 4, 2 * s.Height / 3));
sprite1.ScaleX = (1.5f);
sprite1.ScaleY = -0.5f;
sprite1.RunAction((CCAction)(seq.Copy()));
sprite2 = new CCSprite("grossinis_sister2.png");
sprite2.Position = (new CCPoint(50, 0));
AddChild(aParent);
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2);
//
// Children + Scale using Sprite
// Test 4
//
aParent = new CCSpriteBatchNode("animations/grossini_family");
sprite1 = new CCSprite("grossinis_sister1.png");
sprite1.Position = (new CCPoint(3 * s.Width / 4, 2 * s.Height / 3));
sprite1.ScaleX = 1.5f;
sprite1.ScaleY = -0.5f;
sprite1.RunAction((CCAction)(seq.Copy()));
sprite2 = new CCSprite("grossinis_sister2.png");
sprite2.Position = (new CCPoint(50, 0));
AddChild(aParent);
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2);
}
示例11: SpriteBatchNodeChildrenAnchorPoint
public SpriteBatchNodeChildrenAnchorPoint()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
CCNode aParent;
CCSprite sprite1, sprite2, sprite3, sprite4, point;
//
// SpriteBatchNode
//
// parents
aParent = CCSpriteBatchNode.Create("animations/grossini", 50);
AddChild(aParent, 0);
// anchor (0,0)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 4, s.Height / 2));
sprite1.AnchorPoint = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
// anchor (0.5, 0.5)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
sprite1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
// anchor (1,1)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.Position = (new CCPoint(s.Width / 2 + s.Width / 4, s.Height / 2));
sprite1.AnchorPoint = (new CCPoint(1, 1));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
sprite4 = new CCSprite("grossini_dance_04.png");
sprite4.Position = (new CCPoint(0, 0));
sprite4.Scale = 0.5f;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
point.Scale = 0.25f;
point.Position = sprite1.Position;
AddChild(point, 10);
}
示例12: SpriteChildrenChildren
public SpriteChildrenChildren()
{
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist");
CCNode aParent;
CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;
CCActionInterval rot = new CCRotateBy (10, 360);
CCAction seq = new CCRepeatForever (rot);
CCActionInterval rot_back = (CCActionInterval)rot.Reverse();
CCAction rot_back_fe = new CCRepeatForever (rot_back);
//
// SpriteBatchNode: 3 levels of children
//
aParent = new CCNode ();
AddChild(aParent);
// parent
l1 = new CCSprite("father.gif");
l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
l1.RunAction((CCAction)(seq.Copy()));
aParent.AddChild(l1);
CCSize l1Size = l1.ContentSize;
// child left
l2a = new CCSprite("sister1.gif");
l2a.Position = (new CCPoint(-50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
l2a.RunAction((CCAction)(rot_back_fe.Copy()));
l1.AddChild(l2a);
CCSize l2aSize = l2a.ContentSize;
// child right
l2b = new CCSprite("sister2.gif");
l2b.Position = (new CCPoint(+50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
l2b.RunAction((CCAction)(rot_back_fe.Copy()));
l1.AddChild(l2b);
CCSize l2bSize = l2a.ContentSize;
// child left bottom
l3a1 = new CCSprite("child1.gif");
l3a1.Scale = 0.45f;
l3a1.Position = new CCPoint(0 + l2aSize.Width / 2, -100 + l2aSize.Height / 2);
l2a.AddChild(l3a1);
// child left top
l3a2 = new CCSprite("child1.gif");
l3a2.Scale = 0.45f;
l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, +100 + l2aSize.Height / 2));
l2a.AddChild(l3a2);
// child right bottom
l3b1 = new CCSprite("child1.gif");
l3b1.Scale = 0.45f;
l3b1.FlipY = true;
l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -100 + l2bSize.Height / 2));
l2b.AddChild(l3b1);
// child right top
l3b2 = new CCSprite("child1.gif");
l3b2.Scale = 0.45f;
l3b2.FlipY = true;
l3b1.Position = new CCPoint(0 + l2bSize.Width / 2, +100 + l2bSize.Height / 2);
l2b.AddChild(l3b2);
}
示例13: OnEnter
public override void OnEnter()
{
base.OnEnter();
m_background.Parent.RemoveChild(m_background, true);
m_background = null;
CCParallaxNode p = CCParallaxNode.Create();
AddChild(p, 5);
CCSprite p1 = new CCSprite(TestResource.s_back3);
CCSprite p2 = new CCSprite(TestResource.s_back3);
p.AddChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 250));
p.AddChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 50));
m_emitter = CCParticleFlower.Create();
m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);
p1.AddChild(m_emitter, 10);
m_emitter.Position = new CCPoint(250, 200);
CCParticleSun par = CCParticleSun.Create();
p2.AddChild(par, 10);
par.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);
CCActionInterval move = new CCMoveBy (4, new CCPoint(300, 0));
CCFiniteTimeAction move_back = move.Reverse();
CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
p.RunAction(new CCRepeatForever ((CCActionInterval) seq));
}
示例14: SpriteBatchNodeChildrenZ
public SpriteBatchNodeChildrenZ()
{
CCSize s = CCDirector.SharedDirector.WinSize;
// parents
CCSpriteBatchNode batch;
CCSprite sprite1, sprite2, sprite3;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");
// test 1
batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
batch.AddChild(sprite1);
sprite1.AddChild(sprite2, 2);
sprite1.AddChild(sprite3, -2);
// test 2
batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(2 * s.Width / 3, s.Height / 2));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(20, 30));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(-20, 30));
batch.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
// test 3
batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(s.Width / 2 - 90, s.Height / 4));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(s.Width / 2 - 60, s.Height / 4));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(s.Width / 2 - 30, s.Height / 4));
batch.AddChild(sprite1, 10);
batch.AddChild(sprite2, -10);
batch.AddChild(sprite3, -5);
// test 4
batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite1.Position = (new CCPoint(s.Width / 2 + 30, s.Height / 4));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite2.Position = (new CCPoint(s.Width / 2 + 60, s.Height / 4));
sprite3 = new CCSprite("grossini_dance_03.png");
sprite3.Position = (new CCPoint(s.Width / 2 + 90, s.Height / 4));
batch.AddChild(sprite1, -10);
batch.AddChild(sprite2, -5);
batch.AddChild(sprite3, -2);
}