本文整理汇总了C#中CocosSharp.CCSprite.RunAction方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.RunAction方法的具体用法?C# CCSprite.RunAction怎么用?C# CCSprite.RunAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCSprite
的用法示例。
在下文中一共展示了CCSprite.RunAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: performanceActions
private void performanceActions(CCSprite pSprite)
{
CCSize size = Layer.VisibleBoundsWorldspace.Size;
pSprite.Position = new CCPoint((CCRandom.Next() % (int) size.Width), (CCRandom.Next() % (int) size.Height));
float period = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
CCRotateBy rot = new CCRotateBy (period, 360.0f * CCRandom.Float_0_1());
var rot_back = rot.Reverse();
CCAction permanentRotation = new CCRepeatForever (new CCSequence(rot, rot_back));
pSprite.RunAction(permanentRotation);
float growDuration = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
CCAction permanentScaleLoop = new CCRepeatForever (new CCSequence (grow, grow.Reverse()));
pSprite.RunAction(permanentScaleLoop);
}
示例2: 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);
}
示例3: AddNewSpriteWithCoords
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));
sprite.Position = (new CCPoint(p.X, p.Y));
BatchNode.AddChild(sprite);
CCFiniteTimeAction 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);
CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));
sprite.RunAction(new CCRepeatForever (seq));
}
示例4: 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));
var rot = new CCRotateBy (2, 360);
var rot_back = rot.Reverse();
var forever = new CCRepeatForever (rot, rot_back) { Tag = 101 };
// Since Actions are immutable to set the tag differently we need to
// create a new action. Notice that the same actions can be used in
// this case instead of copying them as well.
forever2 = new CCRepeatForever (rot, rot_back) { 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);
}
示例5: OnEnter
public override void OnEnter()
{
base.OnEnter();
float x, y;
CCSize size = Layer.VisibleBoundsWorldspace.Size;
x = size.Width;
y = size.Height;
CCSprite sprite = new CCSprite(grossini);
CCSprite spriteSister1 = new CCSprite(sister1);
CCSprite spriteSister2 = new CCSprite(sister2);
sprite.Scale = 1.5f;
spriteSister1.Scale = 1.5f;
spriteSister2.Scale = 1.5f;
sprite.Position = size.Center;
spriteSister1.Position = (new CCPoint(40, y / 2));
spriteSister2.Position = (new CCPoint(x - 40, y / 2));
AddChild(sprite);
AddChild(spriteSister1);
AddChild(spriteSister2);
sprite.RunAction(rot);
spriteSister1.Repeat (5, jump2, jump1);
spriteSister2.Repeat (5, jump1, jump2);
spriteSister1.Repeat (5, rot1, rot2);
spriteSister2.Repeat (5, rot2, rot1);
}
示例6: TextLayer
public TextLayer() : base()
{
Camera = AppDelegate.SharedCamera;
contentLayer = new CCLayer();
CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);
contentLayer.Camera = contentCamera;
var bg = new CCSprite(TestResource.s_back3);
BaseNode = bg;
contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
contentLayer.AddChild(colorBackground, -1);
}
示例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));
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);
}
示例8: TextLayer
public TextLayer() : base()
{
Color = new CCColor3B(32, 128, 32);
Opacity = 255;
BaseNode = new CCNodeGrid();
var effect = CurrentAction;
BaseNode.RunAction(effect);
AddChild(BaseNode, 0, EffectTestScene.kTagBackground);
var bg = new CCSprite(TestResource.s_back3);
BaseNode.AddChild(bg, 0);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
}
示例9: TextLayer
public TextLayer() : base()
{
contentLayer = new CCLayer();
CCCamera contentCamera = Camera;
contentLayer.Camera = contentCamera;
var bg = new CCSprite(TestResource.s_back3);
BaseNode = bg;
contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);
var Kathia = new CCSprite(TestResource.s_pPathSister2);
BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);
var sc = new CCScaleBy(2, 5);
var sc_back = sc.Reverse();
Kathia.RunAction(new CCRepeatForever(sc, sc_back));
var Tamara = new CCSprite(TestResource.s_pPathSister1);
BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);
var sc2 = new CCScaleBy(2, 5);
var sc2_back = sc2.Reverse();
Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
contentLayer.AddChild(colorBackground, -1);
}
示例10: IntervalLayer
public IntervalLayer()
{
m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;
CCSize s = Layer.VisibleBoundsWorldspace.Size;
// sun
CCParticleSystem sun = new CCParticleSun(new CCPoint(s.Width / 2, s.Height / 2));
sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
sun.Position = (new CCPoint(s.Width - 32, s.Height - 32));
sun.TotalParticles = 130;
sun.Life = (0.6f);
AddChild(sun);
// timers
m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
Schedule ();
Schedule(step1);
Schedule(step2, 0);
Schedule(step3, 1.0f);
Schedule(step4, 2.0f);
m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2);
m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2);
m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2);
m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2);
m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2);
AddChild(m_label0);
AddChild(m_label1);
AddChild(m_label2);
AddChild(m_label3);
AddChild(m_label4);
// Sprite
CCSprite sprite = new CCSprite(s_pPathGrossini);
sprite.Position = new CCPoint(40, 50);
CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4);
AddChild(sprite);
sprite.RunAction(new CCRepeatForever (
(CCFiniteTimeAction) (new CCSequence(jump, jump.Reverse())))
);
// pause button
CCMenuItem item1 = new CCMenuItemFont("Pause", onPause);
CCMenu menu = new CCMenu(item1);
menu.Position = new CCPoint(s.Width / 2, s.Height - 50);
AddChild(menu);
}
示例11: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize winSize = VisibleBoundsWorldspace.Size;
float x = winSize.Center.X;
float y = winSize.Center.Y;
//var widgetSize = _widget->getContentSize();
var moveTo = new CCMoveBy(1.0f, new CCPoint(30, 0));
var moveBack = moveTo.Reverse();
var rotateBy = new CCRotateBy(1.0f, 180);
var scaleBy = new CCScaleTo(1.0f, -2.0f);
var action = new CCSequence(moveTo, moveBack, rotateBy, scaleBy);
var normalSprite1 = new CCSprite("Images/animationbuttonnormal.png");
normalSprite1.Position = winSize.Center;
normalSprite1.PositionX -= 100;
normalSprite1.PositionY += 100;
normalSprite1.FlipY = true;
AddChild(normalSprite1);
normalSprite1.RunAction(action);
var normalSprite2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
normalSprite2.Position = winSize.Center;
normalSprite2.PositionX -= 80;
normalSprite2.PositionY += 100;
normalSprite2.IsScale9Enabled = false;
normalSprite2.Opacity = 100;
AddChild(normalSprite2);
normalSprite2.Color = CCColor3B.Green;
normalSprite2.RunAction(action);
var sp1 = new CCScale9Sprite("Images/animationbuttonnormal.png");
sp1.Position = winSize.Center;
sp1.PositionX -= 100;
sp1.PositionY -= 50;
sp1.Scale = 1.2f;
sp1.ContentSize = new CCSize(100, 100);
sp1.Color = CCColor3B.Green;
AddChild(sp1);
sp1.RunAction(action);
var sp2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
sp2.Position = winSize.Center;
sp2.PositionX += 100;
sp2.PositionY -= 50;
sp2.PreferredSize = sp1.ContentSize * 1.2f;
sp2.ContentSize = new CCSize(100, 100);
sp2.Color = CCColor3B.Green;
AddChild(sp2);
sp2.RunAction(action);
}
示例12: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = Layer.VisibleBoundsWorldspace.Size;
CCSprite pGrossini = new CCSprite(s_pPathGrossini);
AddChild(pGrossini, 0, (int)KTag.kTagGrossini);
pGrossini.Position = new CCPoint(s.Width / 2, s.Height / 2);
pGrossini.RunAction(new CCScaleBy(2, 2));
Application.ActionManager.PauseTarget(pGrossini);
pGrossini.RunAction(new CCRotateBy (2, 360));
this.Schedule(resumeGrossini, 3.0f);
}
示例13: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSprite grossini = new CCSprite(s_pPathGrossini);
AddChild(grossini, 0, 2);
grossini.Position = (new CCPoint(200, 200));
grossini.RunAction(new CCSequence(
new CCMoveBy (1, new CCPoint(150, 0)),
new CCCallFuncN(bugMe))
);
}
示例14: 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;
}
示例15: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSprite child = new CCSprite(s_pPathGrossini);
child.Position = Layer.VisibleBoundsWorldspace.Size.Center;
AddChild(child, 1);
//Sum of all action's duration is 1.5 second.
child.RunAction(new CCRotateBy (1.5f, 90));
child.RunActions (new CCDelayTime (1.4f), new CCFadeOut (1.1f));
//After 1.5 second, self will be removed.
RunActions (new CCDelayTime (1.4f), new CCCallFunc ((removeThis)));
}