本文整理汇总了C#中Cocos2D.CCSprite类的典型用法代码示例。如果您正苦于以下问题:C# CCSprite类的具体用法?C# CCSprite怎么用?C# CCSprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCSprite类属于Cocos2D命名空间,在下文中一共展示了CCSprite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HighScoreLayer
public HighScoreLayer (int score): base()
{
currentScore = score;
var batchnode = GetChildByTag ((int)Tags.SpriteManager) as CCSpriteBatchNode;
var title = new CCSprite(batchnode.Texture,new CCRect(608,192,225,57));
title.Position=new CCPoint(160,240);
batchnode.AddChild (title);
var button1 = new CCMenuItemImage("Images/playAgainButton", "Images/playAgainButton",
new Action<object>(delegate(object o) {
CCDirector.SharedDirector.ReplaceScene(new CCTransitionFade(.5f, GameLayer.Scene, new CCColor3B(255,255,255)));
}));
var button2 = new CCMenuItemImage("Images/changePlayerButton", "Images/changePlayerButton", new Action<object>(delegate (object sender) {
// do nothing
}));
var menu = new CCMenu(button1,button2);
menu.Position=new CCPoint(160,58);
menu.AlignItemsVerticallyWithPadding(9);
AddChild (menu);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:27,代码来源:HighScoreLayer.cs
示例2: GameLayer
public GameLayer()
{
TouchEnabled = true;
localBananas = new List<CCSprite> ();
localMonkey = new CCSprite ("MonkeyLocal");
localMonkey.PositionY = 0;
localMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
AddChild (localMonkey);
remoteMonkey = new CCSprite ("MonkeyRemote");
remoteMonkey.PositionY = CCDirector.SharedDirector.WinSize.Height - remoteMonkey.ContentSizeInPixels.Height/2;
remoteMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
AddChild (remoteMonkey);
if (!Context.isRoomCreator) {
byte[] message = buildStartMessage ();
sendWarpUpdate (message);
beginLocalGame ();
}
Color = new CCColor3B (XNA.Color.ForestGreen);
Opacity = 255;
}
开发者ID:nightsnaker,项目名称:XamarinMultiplayerBananas,代码行数:26,代码来源:GameLayer.cs
示例3: SpriteBatchNodeReorderIssue767
public SpriteBatchNodeReorderIssue767()
{
CCSize s = CCDirector.SharedDirector.WinSize;
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("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("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("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("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("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("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("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);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:60,代码来源:SpriteBatchNodeReorderIssue767.cs
示例4: updateQuantityOfNodes
public override void updateQuantityOfNodes()
{
CCSize s = CCDirector.SharedDirector.WinSize;
// increase nodes
if (currentQuantityOfNodes < quantityOfNodes)
{
StartTimer();
for (int i = 0; i < (quantityOfNodes - currentQuantityOfNodes); i++)
{
CCSprite sprite = new CCSprite(batchNode.Texture, new CCRect(0, 0, 32, 32));
batchNode.AddChild(sprite);
sprite.Position = new CCPoint(CCRandom.Next() * s.Width, CCRandom.Next() * s.Height);
sprite.Visible = false;
}
EndTimer("Current Quantity: add");
}
// decrease nodes
else if (currentQuantityOfNodes > quantityOfNodes)
{
StartTimer();
for (int i = 0; i < (currentQuantityOfNodes - quantityOfNodes); i++)
{
int index = currentQuantityOfNodes - i - 1;
batchNode.RemoveChildAtIndex(index, true);
}
EndTimer("Current Quantity: add");
}
currentQuantityOfNodes = quantityOfNodes;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:31,代码来源:AddRemoveSpriteSheet.cs
示例5: SpriteZOrder
public SpriteZOrder()
{
m_dir = 1;
CCSize s = CCDirector.SharedDirector.WinSize;
float step = s.Width / 11;
for (int i = 0; i < 5; i++)
{
CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
AddChild(sprite, i);
}
for (int i = 5; i < 10; i++)
{
CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
sprite.Position = new CCPoint((i + 1) * step, s.Height / 2);
AddChild(sprite, 14 - i);
}
CCSprite sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 0, 85, 121));
AddChild(sprite1, -1, (int)kTagSprite.kTagSprite1);
sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2 - 20));
sprite1.Scale = 6;
sprite1.Color = new CCColor3B(Color.Red);
Schedule(reorderSprite, 1);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:29,代码来源:SpriteZOrder.cs
示例6: SpriteBatchNodeAliased
public SpriteBatchNodeAliased()
{
CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 10);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
sprite1.Position = (new CCPoint(s.Width / 2 - 100, s.Height / 2));
batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
CCSprite sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
sprite2.Position = (new CCPoint(s.Width / 2 + 100, s.Height / 2));
batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
CCActionInterval scale = new CCScaleBy(2, 5);
CCActionInterval scale_back = (CCActionInterval)scale.Reverse();
CCActionInterval seq = (CCActionInterval)(new CCSequence(scale, scale_back));
CCAction repeat = new CCRepeatForever (seq);
CCAction repeat2 = (CCAction)(repeat.Copy());
sprite1.RunAction(repeat);
sprite2.RunAction(repeat2);
}
开发者ID:rtabbara,项目名称:cocos2d-xna,代码行数:25,代码来源:SpriteBatchNodeAliased.cs
示例7: performanceRotationScale
private void performanceRotationScale(CCSprite pSprite)
{
CCSize size = CCDirector.SharedDirector.WinSize;
pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
pSprite.Rotation = CCRandom.Float_0_1() * 360;
pSprite.Scale = CCRandom.Float_0_1() * 2;
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:7,代码来源:SpritePerformTest3.cs
示例8: Test5
public Test5()
{
CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
sp2 = new CCSprite(TestResource.s_pPathSister2);
sp1.Position = (new CCPoint(100, 160));
sp2.Position = (new CCPoint(380, 160));
CCRotateBy rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse() as CCActionInterval;
CCAction forever = new CCRepeatForever ((CCActionInterval)new CCSequence(rot, rot_back));
forever2 = (CCAction) (forever.Copy());
forever.Tag = (101);
forever2.Tag = (102);
AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
RemoveChild(sp2, true);
AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
// Sprite 1 should run and run
// Sprite 2 should stop
sp1.RunAction(forever);
sp2.RunAction(forever2);
// Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
// ScheduleOnce(Stage2OfTest, 2.0f);
Schedule(addAndRemove, 2.0f);
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:31,代码来源:Test5.cs
示例9: SpriteBatchNodeZOrder
public SpriteBatchNodeZOrder()
{
m_dir = 1;
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
CCSize s = CCDirector.SharedDirector.WinSize;
float step = s.Width / 11;
for (int i = 0; i < 5; i++)
{
CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
batch.AddChild(sprite, i);
}
for (int i = 5; i < 10; i++)
{
CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
sprite.Position = new CCPoint((i + 1) * step, s.Height / 2);
batch.AddChild(sprite, 14 - i);
}
CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 0, 85, 121));
batch.AddChild(sprite1, -1, (int)kTagSprite.kTagSprite1);
sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2 - 20));
sprite1.Scale = 6;
sprite1.Color = new CCColor3B(Color.Red);
Schedule(reorderSprite, 1);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:34,代码来源:SpriteBatchNodeZOrder.cs
示例10: 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)new CCSequence(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);
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:31,代码来源:Test6.cs
示例11: Init
public override bool Init()
{
InitWithColor(new CCColor4B(0, 0, 255, 255));
var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked);
var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked);
var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked);
var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked);
CCMenu menu = new CCMenu(item0, item1, item2, item3);
menu.AlignItemsVertically();
AddChild(menu);
CCSize s = CCDirector.SharedDirector.WinSize;
CCSprite sprite = new CCSprite(s_pPathGrossini);
AddChild(sprite);
sprite.Position = new CCPoint(s.Width /2, 40);
CCActionInterval rotate = new CCRotateBy (2, 360);
CCAction repeat = new CCRepeatForever (rotate);
sprite.RunAction(repeat);
Schedule(testDealloc);
return true;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:27,代码来源:SceneTestLayer3.cs
示例12: TableCellAtIndex
public virtual CCTableViewCell TableCellAtIndex(CCTableView table, int idx)
{
string str = idx.ToString();
var cell = table.DequeueCell();
if (cell == null) {
cell = new CustomTableViewCell();
var sprite = new CCSprite("Images/Icon");
sprite.AnchorPoint = CCPoint.Zero;
sprite.Position = new CCPoint(0, 0);
cell.AddChild(sprite);
var label = new CCLabelTTF(str, "Helvetica", 20.0f);
label.Position = CCPoint.Zero;
label.AnchorPoint = CCPoint.Zero;
label.Tag = 123;
cell.AddChild(label);
}
else
{
var label = (CCLabelTTF)cell.GetChildByTag(123);
label.Label = (str);
}
return cell;
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:27,代码来源:TableViewTestScene.cs
示例13: CreateScaledMenuItemLabel
public static CCMenuItem CreateScaledMenuItemLabel(CCSize buttonSize, int labelPadding, float strokeSize, CCColor3B textColor, CCColor3B strokeColor, CCColor3B backColor, string labelText, Action action)
{
var menuItem = action != null ? new CCMenuItem(o => action()) : new CCMenuItem();
var labelSize = new CCSize(buttonSize.Width - labelPadding, buttonSize.Height - labelPadding);
// Add background
var blockSprite = new CCSprite("images/Block_Back");
blockSprite.ScaleTo(buttonSize);
blockSprite.Color = backColor;
menuItem.AddChild(blockSprite);
menuItem.ContentSize = buttonSize;
// Add label
var labelTtf = new CCLabelTTF(labelText, "arial-24", 10);
labelTtf.Color = textColor;
// Add Stroke to label
// if (strokeSize > 0) labelTtf.AddStroke(strokeSize, strokeColor);
if (labelTtf.ContentSize.Width > labelSize.Width)
{
labelTtf.ScaleTo(labelSize);
}
menuItem.AddChild(labelTtf);
return menuItem;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:30,代码来源:MenuTestScene.cs
示例14: addNewSpriteWithCoords
public void addNewSpriteWithCoords(CCPoint p)
{
CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);
int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
int x = (idx % 5) * 85;
int y = (idx / 5) * 121;
CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
BatchNode.AddChild(sprite);
sprite.Position = (new CCPoint(p.X, p.Y));
CCActionInterval action = null;
float random = (float)CCRandom.NextDouble();
if (random < 0.20)
action = new CCScaleBy(3, 2);
else if (random < 0.40)
action = new CCRotateBy (3, 360);
else if (random < 0.60)
action = new CCBlink (1, 3);
else if (random < 0.8)
action = new CCTintBy (2, 0, -255, -255);
else
action = new CCFadeOut (2);
CCActionInterval action_back = (CCActionInterval)action.Reverse();
CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back));
sprite.RunAction(new CCRepeatForever (seq));
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:33,代码来源:SpriteBatchNode1.cs
示例15: RenderTextureCompositeTest
public RenderTextureCompositeTest()
{
var winSize = CCDirector.SharedDirector.WinSize;
var characterSpriteFactory = new CharacterSpriteFactory();
_testSprite = new CCSprite(@"Images\grossini_dance_01");
_testSprite2 = new CCSprite(@"Images\grossini_dance_02");
_swingAnimate = characterSpriteFactory.CreateAnimateAction();
_thrustAnimate = characterSpriteFactory.CreateAnimateAction();
_dodgeAnimate = characterSpriteFactory.CreateAnimateAction();
_collapseAnimate = characterSpriteFactory.CreateAnimateAction();
_swingAnimate2 = characterSpriteFactory.CreateAnimateAction();
_thrustAnimate2 = characterSpriteFactory.CreateAnimateAction();
_dodgeAnimate2 = characterSpriteFactory.CreateAnimateAction();
_collapseAnimate2 = characterSpriteFactory.CreateAnimateAction();
_testSprite.Position = new CCPoint(winSize.Width / 2 -200, winSize.Height / 2 + 100);
AddChild(_testSprite);
_testSprite2.Position = new CCPoint(winSize.Width / 2 + 200, winSize.Height / 2 + 100);
_testSprite2.FlipX = true;
AddChild(_testSprite2);
AnimationLoop();
AnimationLoop2();
}
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:28,代码来源:RenderTextureCompositeTest.cs
示例16: OnEnter
public override void OnEnter()
{
//
// This test MUST be done in 'onEnter' and not on 'init'
// otherwise the paused action will be resumed at 'onEnter' time
//
base.OnEnter();
CCSize s = CCDirector.SharedDirector.WinSize;
CCLabelTTF l = new CCLabelTTF("After 5 seconds grossini should move", "arial", 16);
AddChild(l);
l.Position = (new CCPoint(s.Width / 2, 245));
//
// Also, this test MUST be done, after [super onEnter]
//
CCSprite grossini = new CCSprite(s_pPathGrossini);
AddChild(grossini, 0, kTagGrossini);
grossini.Position = (new CCPoint(200, 200));
CCAction action = new CCMoveBy (1, new CCPoint(150, 0));
CCDirector.SharedDirector.ActionManager.AddAction(action, grossini, true);
Schedule(unpause, 3);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:28,代码来源:PauseTest.cs
示例17: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCActionInterval effect = (CCSequence.FromActions(new CCDelayTime (2.0f), new CCShaky3D(16, false, new CCGridSize(5, 5), 5.0f)));
// cleanup
CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground);
RemoveChild(bg, true);
// background
CCLayerColor layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
AddChild(layer, -10);
CCSprite sprite = new CCSprite("Images/grossini");
sprite.Position = new CCPoint(50, 80);
layer.AddChild(sprite, 10);
// foreground
CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
CCSprite fog = new CCSprite("Images/Fog");
var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
fog.BlendFunc = bf;
layer2.AddChild(fog, 1);
AddChild(layer2, 1);
layer2.RunAction(new CCRepeatForever (effect));
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:28,代码来源:Issue631.cs
示例18: OnEnter
public override void OnEnter()
{
base.OnEnter();
m_grossini = new CCSprite(TestResource.s_pPathGrossini);
m_tamara = new CCSprite(TestResource.s_pPathSister1);
m_kathia = new CCSprite(TestResource.s_pPathSister2);
AddChild(m_grossini, 3);
AddChild(m_kathia, 2);
AddChild(m_tamara, 1);
var s = CCDirector.SharedDirector.WinSize;
m_grossini.Position = new CCPoint(60, 50);
m_kathia.Position = new CCPoint(60, 150);
m_tamara.Position = new CCPoint(60, 250);
var label = new CCLabelTTF(title(), "arial", 32);
AddChild(label);
label.Position = new CCPoint(s.Width / 2, s.Height - 50);
var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);
var menu = new CCMenu(item1, item2, item3);
menu.Position = CCPoint.Zero;
item1.Position = new CCPoint(s.Width / 2 - 100, 30);
item2.Position = new CCPoint(s.Width / 2, 30);
item3.Position = new CCPoint(s.Width / 2 + 100, 30);
AddChild(menu, 1);
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:33,代码来源:EaseActionsTest.cs
示例19: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = CCDirector.SharedDirector.WinSize;
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini.plist");
CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("zwoptex/grossini-generic.plist");
CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121);
layer1.Position = new CCPoint(s.Width / 2 - 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
AddChild(layer1);
sprite1 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_01.png"));
sprite1.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2));
AddChild(sprite1);
sprite1.FlipX = false;
sprite1.FlipY = false;
CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 85, 121);
layer2.Position = new CCPoint(s.Width / 2 + 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
AddChild(layer2);
sprite2 = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName("grossini_dance_generic_01.png"));
sprite2.Position = (new CCPoint(s.Width / 2 + 80, s.Height / 2));
AddChild(sprite2);
sprite2.FlipX = false;
sprite2.FlipY = false;
Schedule(startIn05Secs, 1.0f);
counter = 0;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:35,代码来源:ZwoptexGenericTest.cs
示例20: InitWithMaskSprite
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel,
CCLabelTTF offLabel)
{
if (base.Init())
{
Debug.Assert(maskSprite != null, "Mask must not be nil.");
Debug.Assert(onSprite != null, "onSprite must not be nil.");
Debug.Assert(offSprite != null, "offSprite must not be nil.");
Debug.Assert(thumbSprite != null, "thumbSprite must not be nil.");
TouchEnabled = true;
_on = true;
_switchSprite = new CCControlSwitchSprite();
_switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite,
onLabel, offLabel);
_switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2);
AddChild(_switchSprite);
IgnoreAnchorPointForPosition = false;
AnchorPoint = new CCPoint(0.5f, 0.5f);
ContentSize = _switchSprite.ContentSize;
return true;
}
return false;
}
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:28,代码来源:CCControlSwitch.cs
注:本文中的Cocos2D.CCSprite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论