本文整理汇总了C#中CocosSharp.CCSprite.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.AddChild方法的具体用法?C# CCSprite.AddChild怎么用?C# CCSprite.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCSprite
的用法示例。
在下文中一共展示了CCSprite.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpriteChildrenVisibilityIssue665
public SpriteChildrenVisibilityIssue665()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
aParent = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
// test issue #665
sprite1.Visible = false;
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, 2);
aParent2 = new CCNode();
AddChild(aParent2, 0);
sprite4 = new CCSprite("grossini_dance_01.png");
sprite5 = new CCSprite("grossini_dance_02.png");
sprite6 = new CCSprite("grossini_dance_03.png");
// test issue #665
sprite4.Visible = false;
aParent2.AddChild(sprite4);
sprite4.AddChild(sprite5, -2);
sprite4.AddChild(sprite6, 2);
}
示例2: SpriteBatchNodeChildrenChildren
public SpriteBatchNodeChildrenChildren()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist");
var rot = new CCRotateBy (10, 360);
seq = new CCRepeatForever (rot);
var rot_back = rot.Reverse();
rot_back_fe = new CCRepeatForever (rot_back);
// SpriteBatchNode: 3 levels of children
aParent = new CCSpriteBatchNode("animations/ghosts");
AddChild(aParent);
// parent
l1 = new CCSprite("father.gif");
aParent.AddChild(l1);
// child left
l2a = new CCSprite("sister1.gif");
l1.AddChild(l2a);
// child right
l2b = new CCSprite("sister2.gif");
l1.AddChild(l2b);
// child left bottom
l3a1 = new CCSprite("child1.gif");
l3a1.Scale = 0.45f;
l2a.AddChild(l3a1);
// child left top
l3a2 = new CCSprite("child1.gif");
l3a2.Scale = 0.45f;
l2a.AddChild(l3a2);
// child right bottom
l3b1 = new CCSprite("child1.gif");
l3b1.Scale = 0.45f;
l3b1.FlipY = true;
l2b.AddChild(l3b1);
// child right top
l3b2 = new CCSprite("child1.gif");
l3b2.Scale = 0.45f;
l3b2.FlipY = true;
l2b.AddChild(l3b2);
}
示例3: SpriteChildrenAnchorPoint
public SpriteChildrenAnchorPoint()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
aParent = new CCNode();
AddChild(aParent, 0);
// anchor (0,0)
sprite1 = new CCSprite("grossini_dance_08.png");
sprite1.AnchorPoint = (new CCPoint(0, 0));
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
sprite4 = new CCSprite("grossini_dance_04.png");
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
AddChild(point, 10);
// anchor (0.5, 0.5)
sprite5 = new CCSprite("grossini_dance_08.png");
sprite5.AnchorPoint = (new CCPoint(0.5f, 0.5f));
sprite6 = new CCSprite("grossini_dance_02.png");
sprite7 = new CCSprite("grossini_dance_03.png");
sprite8 = new CCSprite("grossini_dance_04.png");
aParent.AddChild(sprite5);
sprite5.AddChild(sprite6, -2);
sprite5.AddChild(sprite7, -2);
sprite5.AddChild(sprite8, 3);
point2 = new CCSprite("Images/r1");
AddChild(point2, 10);
// anchor (1,1)
sprite9 = new CCSprite("grossini_dance_08.png");
sprite9.AnchorPoint = new CCPoint(1, 1);
sprite10 = new CCSprite("grossini_dance_02.png");
sprite11 = new CCSprite("grossini_dance_03.png");
sprite12 = new CCSprite("grossini_dance_04.png");
aParent.AddChild(sprite9);
sprite9.AddChild(sprite10, -2);
sprite9.AddChild(sprite11, -2);
sprite9.AddChild(sprite12, 3);
point3 = new CCSprite("Images/r1");
AddChild(point3, 10);
}
示例4: SpriteBatchNodeChildrenZ
public SpriteBatchNodeChildrenZ()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
// test 1
batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprite1 = new CCSprite("grossini_dance_01.png");
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
batch.AddChild(sprite1);
sprite1.AddChild(sprite2, 2);
sprite1.AddChild(sprite3, -2);
// test 2
batch2 = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch2, 0, (int)kTags.kTagSpriteBatchNode);
sprite4 = new CCSprite("grossini_dance_01.png");
sprite5 = new CCSprite("grossini_dance_02.png");
sprite6 = new CCSprite("grossini_dance_03.png");
batch.AddChild(sprite4);
sprite4.AddChild(sprite5, -2);
sprite4.AddChild(sprite6, 2);
// test 3
batch3 = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch3, 0, (int)kTags.kTagSpriteBatchNode);
sprite7 = new CCSprite("grossini_dance_01.png");
sprite8 = new CCSprite("grossini_dance_02.png");
sprite9 = new CCSprite("grossini_dance_03.png");
batch3.AddChild(sprite7, 10);
batch3.AddChild(sprite8, -10);
batch3.AddChild(sprite9, -5);
// test 4
batch4 = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch4, 0, (int)kTags.kTagSpriteBatchNode);
sprite10 = new CCSprite("grossini_dance_01.png");
sprite11 = new CCSprite("grossini_dance_02.png");
sprite12 = new CCSprite("grossini_dance_03.png");
batch4.AddChild(sprite10, -10);
batch4.AddChild(sprite11, -5);
batch4.AddChild(sprite12, -2);
}
示例5: SpriteBatchNodeChildrenAnchorPoint
public SpriteBatchNodeChildrenAnchorPoint()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
CCNode aParent;
aParent = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(aParent, 0);
sprite1 = new CCSprite("grossini_dance_08.png");
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
sprite4 = new CCSprite("grossini_dance_04.png");
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2, -2);
sprite1.AddChild(sprite3, -2);
sprite1.AddChild(sprite4, 3);
point = new CCSprite("Images/r1");
AddChild(point, 10);
sprite5 = new CCSprite("grossini_dance_08.png");
sprite6 = new CCSprite("grossini_dance_02.png");
sprite7 = new CCSprite("grossini_dance_03.png");
sprite8 = new CCSprite("grossini_dance_04.png");
aParent.AddChild(sprite5);
sprite5.AddChild(sprite6, -2);
sprite5.AddChild(sprite7, -2);
sprite5.AddChild(sprite8, 3);
point2 = new CCSprite("Images/r1");
AddChild(point2, 10);
sprite9 = new CCSprite("grossini_dance_08.png");
sprite10 = new CCSprite("grossini_dance_02.png");
sprite11 = new CCSprite("grossini_dance_03.png");
sprite12 = new CCSprite("grossini_dance_04.png");
sprite12.Position = (new CCPoint(0, 0));
sprite12.Scale = 0.5f;
aParent.AddChild(sprite9);
sprite9.AddChild(sprite10, -2);
sprite9.AddChild(sprite11, -2);
sprite9.AddChild(sprite12, 3);
point3 = new CCSprite("Images/r1");
AddChild(point3, 10);
}
示例6: AddedToScene
protected override void AddedToScene()
{
base.AddedToScene();
CCSize s = Layer.VisibleBoundsWorldspace.Size;
CCSprite p = new CCSprite(TestResource.s_back3);
AddChild(p, 0);
p.Position = (new CCPoint(s.Width / 2, s.Height / 2));
//p.Opacity = 50;
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;
}
示例7: MakeSpriteZ
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;
}
示例8: 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));
CCFiniteTimeAction rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse();
var forever1 = new CCRepeatForever (rot, rot_back);
AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
sp1.AddChild(sp11);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
sp2.AddChild(sp21);
sp1.RunAction(forever1);
sp11.RunAction(forever1);
sp2.RunAction(forever1);
sp21.RunAction(forever1);
Schedule(addAndRemove, 2.0f);
}
示例9: NodeToWorld3D
public NodeToWorld3D()
{
//
// This code tests that nodeToParent works OK:
// - It tests different anchor Points
// - It tests different children anchor points
parent = new CCNode();
parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
AddChild(parent);
back = new CCSprite(TestResource.s_back3);
parent.AddChild(back, -10);
back.AnchorPoint = CCPoint.Zero;
var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
menu = new CCMenu(item);
menu.AlignItemsVertically();
back.AddChild(menu);
item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);
back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());
parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
}
示例10: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = Layer.VisibleBoundsWorldspace.Size;
var sp1 = new CCSprite(TestResource.s_pPathSister1);
var sp2 = new CCSprite(TestResource.s_pPathSister2);
var sp3 = new CCSprite(TestResource.s_pPathSister1);
var 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);
var a1 = new CCRotateBy (2, 360);
var a2 = new CCScaleBy(2, 2);
var action1 = new CCRepeatForever (a1, a2, a2.Reverse());
sp2.AnchorPoint = (new CCPoint(0, 0));
sp1.RunAction(action1);
sp2.RunAction(action1);
}
示例11: SpriteBatchNodeChildren
public SpriteBatchNodeChildren()
{
CCSpriteBatchNode batch = new CCSpriteBatchNode("animations/grossini", 50);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");
sprite1 = new CCSprite("grossini_dance_01.png");
sprite2 = new CCSprite("grossini_dance_02.png");
sprite3 = new CCSprite("grossini_dance_03.png");
batch.AddChild(sprite1);
sprite1.AddChild(sprite2);
sprite1.AddChild(sprite3);
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[str];
animFrames.Add(frame);
}
animation = new CCAnimation(animFrames, 0.2f);
action = new CCMoveBy (2, new CCPoint(200, 0));
action_back = (CCFiniteTimeAction)action.Reverse();
action_rot = new CCRotateBy (2, 360);
action_s = new CCScaleBy(2, 2);
action_s_back = (CCFiniteTimeAction)action_s.Reverse();
seq2 = (CCFiniteTimeAction)action_rot.Reverse();
}
示例12: SpriteBatchNodeReorderIssue767
public SpriteBatchNodeReorderIssue767()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist", "animations/ghosts");
// SpriteBatchNode: 3 levels of children
aParent = new CCSpriteBatchNode("animations/ghosts");
AddChild(aParent, 0, (int) kTagSprite.kTagSprite1);
// parent
l1 = new CCSprite("father.gif");
aParent.AddChild(l1, 0, (int) kTagSprite.kTagSprite2);
// child left
l2a = new CCSprite("sister1.gif");
l1.AddChild(l2a, -1, (int) kTags.kTagSpriteLeft);
// child right
l2b = new CCSprite("sister2.gif");
l1.AddChild(l2b, 1, (int) kTags.kTagSpriteRight);
// child left bottom
l3a1 = new CCSprite("child1.gif");
l3a1.Scale = (0.65f);
l2a.AddChild(l3a1, -1);
// child left top
l3a2 = new CCSprite("child1.gif");
l3a2.Scale = (0.65f);
l2a.AddChild(l3a2, 1);
// child right bottom
l3b1 = new CCSprite("child1.gif");
l3b1.Scale = (0.65f);
l2b.AddChild(l3b1, -1);
// child right top
l3b2 = new CCSprite("child1.gif");
l3b2.Scale = (0.65f);
l2b.AddChild(l3b2, 1);
}
示例13: SpriteBatchNodeChildrenScale
public SpriteBatchNodeChildrenScale()
{
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini_family.plist");
var rot = new CCRotateBy (10, 360);
seq = new CCRepeatForever(rot);
// Children + Scale using Sprite
// Test 1
aParent = new CCNode();
sprite1 = new CCSprite("grossinis_sister1.png");
sprite2 = new CCSprite("grossinis_sister2.png");
AddChild(aParent);
aParent.AddChild(sprite1);
sprite1.AddChild(sprite2);
// Children + Scale using SpriteBatchNode
// Test 2
aParent2 = new CCSpriteBatchNode("animations/grossini_family");
sprite3 = new CCSprite("grossinis_sister1.png");
sprite4 = new CCSprite("grossinis_sister2.png");
sprite4.Position = (new CCPoint(50, 0));
AddChild(aParent2);
aParent2.AddChild(sprite3);
sprite3.AddChild(sprite4);
// Children + Scale using Sprite
// Test 3
aParent3 = new CCNode ();
sprite5 = new CCSprite("grossinis_sister1.png");
sprite6 = new CCSprite("grossinis_sister2.png");
AddChild(aParent3);
aParent3.AddChild(sprite5);
sprite5.AddChild(sprite6);
// Children + Scale using Sprite
// Test 4
aParent4 = new CCSpriteBatchNode("animations/grossini_family");
sprite7 = new CCSprite("grossinis_sister1.png");
sprite8 = new CCSprite("grossinis_sister2.png");
AddChild(aParent4);
aParent4.AddChild(sprite7);
sprite7.AddChild(sprite8);
}
示例14: AddCardinalImage
private void AddCardinalImage(int p1, int p2) {
var tmp = new CCSprite(Resources.BossCardinal) {
Texture = {IsAntialiased = false},
PositionX = p1,
PositionY = p2,
Scale = 6
};
var blades = new CCSprite(Resources.BossCardinalBlades) {
Scale = 1,
IsAntialiased = false,
PositionX = tmp.Texture.PixelsWide/2,
PositionY = tmp.Texture.PixelsHigh/2
};
blades.AddAction(new CCRepeatForever(new CCRotateBy(0.7f, -120)));
tmp.AddChild(blades, -1);
if (tmp.PositionX > Settings.ScreenWidth/2) {
tmp.FlipX = true;
}
AddChild(tmp);
}
示例15: OnEnter
public override void OnEnter()
{
base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;
Background.Parent.RemoveChild(Background, true);
Background = null;
CCParallaxNode p = new CCParallaxNode();
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));
Emitter = new CCParticleFlower(MidWindowPoint);
Emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);
p1.AddChild(Emitter, 10);
Emitter.Position = new CCPoint(250, 200);
CCParticleSun par = new CCParticleSun(MidWindowPoint);
p2.AddChild(par, 10);
par.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);
CCFiniteTimeAction move = new CCMoveBy (4, new CCPoint(300, 0));
CCFiniteTimeAction move_back = move.Reverse();
CCFiniteTimeAction seq = new CCSequence(move, move_back);
p.RunAction(new CCRepeatForever ((CCFiniteTimeAction) seq));
}