本文整理汇总了C#中CCNode.RunAction方法的典型用法代码示例。如果您正苦于以下问题:C# CCNode.RunAction方法的具体用法?C# CCNode.RunAction怎么用?C# CCNode.RunAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode.RunAction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: OnEnter
public override void OnEnter()
{
base.OnEnter();
CCSize s = Layer.VisibleBoundsWorldspace.Size;
// the root object just rotates around
m_root = new CCSprite(s_pPathR1);
AddChild(m_root, 1);
m_root.Position = new CCPoint(s.Width / 2, s.Height / 2);
// the target object is offset from root, and the streak is moved to follow it
m_target = new CCSprite(s_pPathR1);
m_root.AddChild(m_target);
m_target.Position = new CCPoint(s.Width / 4, 0);
// create the streak object and add it to the scene
streak = new CCMotionStreak(2, 3, 32, CCColor3B.Green, s_streak);
streak.FastMode = true;
AddChild(streak);
// schedule an update on each frame so we can syncronize the streak with the target
Schedule(onUpdate);
var a1 = new CCRotateBy (2, 360);
var action1 = new CCRepeatForever (a1);
var motion = new CCMoveBy (2, new CCPoint(100, 0));
m_root.RunAction(new CCRepeatForever ((CCFiniteTimeAction)new CCSequence(motion, motion.Reverse())));
m_root.RunAction(action1);
var colorAction = new CCRepeatForever ((CCFiniteTimeAction)
new CCSequence(
new CCTintTo (0.2f, 255, 0, 0),
new CCTintTo (0.2f, 0, 255, 0),
new CCTintTo (0.2f, 0, 0, 255),
new CCTintTo (0.2f, 0, 255, 255),
new CCTintTo (0.2f, 255, 255, 0),
new CCTintTo (0.2f, 255, 0, 255),
new CCTintTo (0.2f, 255, 255, 255)
)
);
streak.RunAction(colorAction);
}
示例3: bugMe
public void bugMe(CCNode node)
{
node.StopAllActions(); //After this stop next action not working, if remove this stop everything is working
node.RunAction(new CCScaleTo(2, 2));
}
示例4: RepeatForever
public void RepeatForever(CCNode sender)
{
sender.RunAction(repeat);
}
示例5: TextLayer
public TextLayer()
: base()
{
SizeF s = CCDirector.SharedDirector ().WinSize ();
float x = s.Width;
float y = s.Height;
CCNode node = new CCNode ();
CCAction effectClass = RestartAction (3f);
node.RunAction (effectClass);
this.AddChild (node, 0, (int)EffectLayers.kTagBackground);
CCSprite bg = new CCSprite ("background3.png", true);
node.AddChild (bg, 0);
bg.Position = new PointF(x/2, y/2);
CCSprite grossini = new CCSprite ("grossinis_sister2.png", true);
node.AddChild (grossini, 1);
grossini.Position = new PointF(x/3, y/2);
CCScaleBy sc = new CCScaleBy (2, 5);
CCActionInterval sc_back = sc.Reverse ();
grossini.RunAction (new CCRepeatForever (new CCSequence (sc, sc_back)));
CCSprite tamara = new CCSprite ("grossinis_sister1.png", true);
node.AddChild (tamara, 1, (int)EffectLayers.kTagSprite2);
tamara.Position = new PointF (2*x/3, y/2);
CCScaleBy sc2 = new CCScaleBy (2, 5);
CCActionInterval sc2_back = sc2.Reverse ();
tamara.RunAction (new CCRepeatForever (new CCSequence (sc2, sc2_back)));
CCLabelTTF label = new CCLabelTTF (effectsList[actionIdx].Replace("Demo", ""), "Marker Felt", 32);
label.Position = new PointF (x/2, y-80);
this.AddChild (label);
label.Tag = (int)EffectLayers.kTagLabel;
//menu
CCMenuItemImage item1 = new CCMenuItemImage ("b1.png", "b2.png", null, BackCallback);
CCMenuItemImage item2 = new CCMenuItemImage ("r1.png", "r2.png", null, RestartCallback);
CCMenuItemImage item3 = new CCMenuItemImage ("f1.png", "f2.png", null, NextCallback);
CCMenu menu = new CCMenu (item1, item2, item3);
menu.Position = PointF.Empty;
item1.Position = new PointF(s.Width/2 - item2.ContentSize.Width*2, item2.ContentSize.Height/2);
item2.Position = new PointF( s.Width/2, item2.ContentSize.Height/2);
item3.Position = new PointF( s.Width/2 + item2.ContentSize.Width*2, item2.ContentSize.Height/2);
this.AddChild (menu, 1);
this.Schedule (new MonoMac.ObjCRuntime.Selector ("checkAnim:"));
}
示例6: AddedToScene
protected override void AddedToScene()
{
base.AddedToScene();
contentLayer = new CCLayer();
Window.IsUseDepthTesting = true;
node = new CCNode(Layer.VisibleBoundsWorldspace.Size);
node.AnchorPoint = CCPoint.AnchorMiddle;
node.IgnoreAnchorPointForPosition = true;
AddChild(contentLayer);
contentLayer.AddChild(node);
CCSize layerSize = contentLayer.VisibleBoundsWorldspace.Size;
float step = layerSize.Width / 12;
// small capacity. Testing resizing.
// Don't use capacity=1 in your real game. It is expensive to resize the capacity
batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
node.AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);
sprites = new CCSprite[numOfSprites];
for (int i = 0; i < 5; i++)
{
sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
sprites[i].Position = (new CCPoint((i + 1) * step, layerSize.Height / 2));
sprites[i].VertexZ = (10 + i * 20);
batch.AddChild(sprites[i], 0);
}
for (int i = 5; i < 11; i++)
{
sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
sprites[i].Position = (new CCPoint((i + 1) * step, layerSize.Height / 2));
sprites[i].VertexZ = 10 + (10 - i) * 20;
batch.AddChild(sprites[i], 0);
}
// camera uses the center of the image as the pivoting point
node.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
}
示例7: RunAction
private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration)
{
List<CCBKeyframe> keyframes = pSeqProp.Keyframes;
int numKeyframes = keyframes.Count;
if (numKeyframes > 1)
{
// Make an animation!
var actions = new List<CCFiniteTimeAction>();
CCBKeyframe keyframeFirst = keyframes[0];
float timeFirst = keyframeFirst.Time + fTweenDuration;
if (timeFirst > 0)
{
actions.Add(new CCDelayTime(timeFirst));
}
for (int i = 0; i < numKeyframes - 1; ++i)
{
CCBKeyframe kf0 = keyframes[i];
CCBKeyframe kf1 = keyframes[i + 1];
CCFiniteTimeAction action = GetAction(kf0, kf1, pSeqProp.Name, node);
if (action != null)
{
// Apply easing
action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt);
actions.Add(action);
}
}
if (actions.Count > 1)
{
CCFiniteTimeAction seq = new CCSequence(actions.ToArray());
node.RunAction(seq);
}
else
{
node.RunAction(actions[0]);
}
}
}
示例8: SetAnimatedProperty
private void SetAnimatedProperty(string pPropName, CCNode node, object pValue, float fTweenDuraion)
{
if (fTweenDuraion > 0)
{
// Create a fake keyframe to generate the action from
var kf1 = new CCBKeyframe();
kf1.Value = pValue;
kf1.Time = fTweenDuraion;
kf1.EasingType = CCBEasingType.Linear;
// Animate
CCFiniteTimeAction tweenAction = GetAction(null, kf1, pPropName, node);
node.RunAction(tweenAction);
}
else
{
// Just set the value
if (pPropName == "position")
{
// Get position type
var array = (List<CCBValue>)GetBaseValue(node, pPropName);
var type = (CCBPositionType)array[2].GetIntValue();
// Get relative position
var value = (List<CCBValue>)pValue;
float x = value[0].GetFloatValue();
float y = value[1].GetFloatValue();
node.Position = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, GetContainerSize(node.Parent), pPropName);
}
else if (pPropName == "scale")
{
// Get scale type
var array = (List<CCBValue>)GetBaseValue(node, pPropName);
var type = (CCBScaleType)array[2].GetIntValue();
// Get relative scale
var value = (List<CCBValue>)pValue;
float x = value[0].GetFloatValue();
float y = value[1].GetFloatValue();
CCBHelper.SetRelativeScale(node, x, y, type, pPropName);
}
else if (pPropName == "skew")
{
// Get relative scale
var value = (List<CCBValue>)pValue;
float x = value[0].GetFloatValue();
float y = value[1].GetFloatValue();
node.SkewX = x;
node.SkewY = y;
}
else
{
// [node setValue:value forKey:name];
// TODO only handle rotation, opacity, displayFrame, color
if (pPropName == "rotation")
{
float rotate = ((CCBValue)pValue).GetFloatValue();
node.Rotation = rotate;
}
else if (pPropName == "rotationX")
{
float rotate = ((CCBValue)pValue).GetFloatValue();
node.RotationX = rotate;
}
else if (pPropName == "rotationY")
{
float rotate = ((CCBValue)pValue).GetFloatValue();
node.RotationY = rotate;
}
else if (pPropName == "opacity")
{
byte opacity = ((CCBValue)pValue).GetByteValue();
node.Opacity = opacity;
}
else if (pPropName == "displayFrame")
{
((CCSprite)node).SpriteFrame = (CCSpriteFrame)pValue;
}
else if (pPropName == "color")
{
var color = (CCColor3BWapper)pValue;
node.Color = color.Color;
}
else if (pPropName == "visible")
{
bool visible = ((CCBValue)pValue).GetBoolValue();
node.Visible = visible;
}
else
{
CCLog.Log("unsupported property name is {0}", pPropName);
Debug.Assert(false, "unsupported property now");
}
}
}
//.........这里部分代码省略.........