public CCActionState (CCAction action, CCNode target) { this.Action = action; this.Target = target; this.OriginalTarget = target; if (target != null) this.Layer = target.Layer; }
public void AddAction(Transform transform, CCAction action) { actionList.Add(action); if (Actions.ContainsKey(transform)) { Actions[transform].Add(action); } else { Actions.Add(transform,new List<CCAction> { action }); } }
public static CCAction GetSSAction() { CCAction action = ScriptableObject.CreateInstance <CCAction>(); return(action); }
public void removeAction(CCAction action){ if (action == null) return; System.Object target = action.originalTarget; tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { int i = element.actions.IndexOf(action); if(i != -1){ removeActionAtIndex(i, element); } } }
protected CCAction(CCAction action) { m_nTag = action.m_nTag; m_pOriginalTarget = action.m_pOriginalTarget; m_pTarget = action.m_pTarget; }
/// <summary> /// Removes an action from the running action list /// </summary> public void StopAction(CCAction action) { //CCActionManager.sharedManager().removeAction(action); throw new NotImplementedException(); }
// -(NSSet *) pauseAllRunningActions // { // NSMutableSet* idsWithActions = [NSMutableSet setWithCapacity:50]; // // for(tHashElement *element=targets; element != NULL; element=element->hh.next) { // if( !element->paused ) { // element->paused = YES; // [idsWithActions addObject:element->target]; // } // } // return idsWithActions; // } // // -(void) resumeTargets:(NSSet *)targetsToResume // { // for(id target in targetsToResume) { // [self resumeTarget:target]; // } // } #endregion #region ActionManager - run public void addAction(CCAction action, System.Object target, bool paused){ NSUtils.Assert( action != null, "Argument action must be non-nil"); NSUtils.Assert( target != null, "Argument target must be non-nil"); tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element == null) { element = new tHashElement(); element.paused = paused; element.target = target; _targets.HASH_ADD_INT(target.GetHashCode(), element); } actionAllocWithHashElement (element); NSUtils.Assert (!element.actions.Contains (action), "runAction: Action already running"); element.actions.Add (action); action.startWithTarget (target); }
/** Removes an action from the running action list */ public void stopAction(CCAction action){ _actionManager.removeAction (action); }
/// <summary> /// Executes an action, and returns the action that is executed. /// The node becomes the action's target. /// @warning Starting from v0.8 actions don't retain their target anymore. /// @return /// </summary> /// <returns>An Action pointer</returns> public CCAction RunAction(CCAction action) { //Debug.Assert(action != null, "Argument must be non-nil"); //CCActionManager.sharedManager().addAction(action, this, !IsRunning); //return action; throw new NotImplementedException(); }
protected CCAction(CCAction action) { m_nTag = action.m_nTag; }
public override void Play(){ if (_startFrame == _endFrame) { GotoFrame(_startFrame); return; } Stop (); GotoFrame (_startFrame); MovieImpAction movieAction = new MovieImpAction (this, _startFrame, _endFrame); if (_loop) { _action = new CCRepeatForever(movieAction); } else { _action = movieAction; } _view.runAction (_action); }
private void HandleMoveCircle(CCTouch touch) { const float timeToTake = 1.5f; // in seconds CCFiniteTimeAction coreAction = null; CCNode nodeToAddTo = drawNodeRoot; switch (VariableOptions [currentVariableIndex]) { case "Position": coreAction = new CCMoveTo(timeToTake, touch.Location); break; case "Scale": var distance = CCPoint.Distance(touch.Location, drawNodeRoot.Position); var desiredScale = distance / DefaultCircleRadius; coreAction = new CCScaleTo(timeToTake, desiredScale); break; case "Rotation": float differenceY = touch.Location.Y - drawNodeRoot.PositionY; float differenceX = touch.Location.X - drawNodeRoot.PositionX; float angleInDegrees = -1 * CCMathHelper.ToDegrees( (float)System.Math.Atan2(differenceY, differenceX)); coreAction = new CCRotateTo(timeToTake, angleInDegrees); break; case "LineWidth": coreAction = new LineWidthAction(timeToTake, touch.Location.X / 40.0f); nodeToAddTo = lineNode; break; } CCAction easing = null; switch (EasingOptions [currentEasingIndex]) { case "<None>": // no easing, do nothing, it will be handled below break; case "CCEaseBack": if (currentInOutIndex == 0) { easing = new CCEaseBackOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBackIn(coreAction); } else { easing = new CCEaseBackInOut(coreAction); } break; case "CCEaseBounce": if (currentInOutIndex == 0) { easing = new CCEaseBounceOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBounceIn(coreAction); } else { easing = new CCEaseBounceInOut(coreAction); } break; case "CCEaseElastic": if (currentInOutIndex == 0) { easing = new CCEaseElasticOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseElasticIn(coreAction); } else { easing = new CCEaseElasticInOut(coreAction); } break; case "CCEaseExponential": if (currentInOutIndex == 0) { easing = new CCEaseExponentialOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseExponentialIn(coreAction); } else { easing = new CCEaseExponentialInOut(coreAction); } break; case "CCEaseSine": if (currentInOutIndex == 0) { easing = new CCEaseSineOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseSineIn(coreAction); } else { easing = new CCEaseSineInOut(coreAction); } break; } if (easing != null) { nodeToAddTo.AddAction(easing); } else { nodeToAddTo.AddAction(coreAction); } }
public override void OnEnter() { base.OnEnter(); // create a transparent color layer // in which we are going to add our rendertextures var color = new CCColor4B(0, 0, 0, 0); CCSize size = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(color); // create the first render texture for inScene CCRenderTexture inTexture = new CCRenderTexture((int)size.Width, (int)size.Height); if (null == inTexture) { return; } inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); inTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render inScene to its texturebuffer inTexture.Begin(); m_pInScene.Visit(); inTexture.End(); // create the second render texture for outScene CCRenderTexture outTexture = new CCRenderTexture((int)size.Width, (int)size.Height); outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); outTexture.Position = new CCPoint(size.Width / 2, size.Height / 2); outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render outScene to its texturebuffer outTexture.Begin(); m_pOutScene.Visit(); outTexture.End(); // create blend functions var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha var blend2 = CCBlendFunc.NonPremultiplied; // we are going to blend outScene via alpha // set blendfunctions inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; // add render textures to the layer layer.AddChild(inTexture); layer.AddChild(outTexture); // initial opacity: inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; // create the blend action CCAction layerAction = CCSequence.FromActions ( new CCFadeTo(m_fDuration, 0), new CCCallFunc((HideOutShowIn)), new CCCallFunc((Finish)) ); //// run the blend action outTexture.Sprite.RunAction(layerAction); // add the layer (which contains our two rendertextures) to the scene AddChild(layer, 2, kSceneFade); }
/// <summary> /// 运行 CCAction /// </summary> /// <param name="s"></param> /// <param name="action"></param> public static void RunAction(this Transform s, CCAction action) { action.SetTarget(s); CCActionMgr.Instance.AddAction(s,action); }
private void HandleMoveCircle(CCTouch touch) { const float timeToTake = 1.5f; // in seconds CCFiniteTimeAction coreAction = null; // By default all actions will be added directly to the // root node - it has values for Position, Scale, and Rotation. CCNode nodeToAddTo = drawNodeRoot; switch (VariableOptions [currentVariableIndex]) { case "Position": coreAction = new CCMoveTo(timeToTake, touch.Location); break; case "Scale": var distance = CCPoint.Distance(touch.Location, drawNodeRoot.Position); var desiredScale = distance / DefaultCircleRadius; coreAction = new CCScaleTo(timeToTake, desiredScale); break; case "Rotation": float differenceY = touch.Location.Y - drawNodeRoot.PositionY; float differenceX = touch.Location.X - drawNodeRoot.PositionX; float angleInDegrees = -1 * CCMathHelper.ToDegrees( (float)System.Math.Atan2(differenceY, differenceX)); coreAction = new CCRotateTo(timeToTake, angleInDegrees); break; case "LineWidth": coreAction = new LineWidthAction(timeToTake, touch.Location.X / 40.0f); // The LineWidthAction is a special action designed to work only on // LineNode instances, so we have to set the nodeToAddTo to the lineNode: nodeToAddTo = lineNode; break; } CCAction easing = null; switch (EasingOptions [currentEasingIndex]) { case "<None>": // no easing, do nothing. We'll add the coreAction // instead of easing break; case "CCEaseBack": if (currentInOutIndex == 0) { easing = new CCEaseBackOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBackIn(coreAction); } else { easing = new CCEaseBackInOut(coreAction); } break; case "CCEaseBounce": if (currentInOutIndex == 0) { easing = new CCEaseBounceOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBounceIn(coreAction); } else { easing = new CCEaseBounceInOut(coreAction); } break; case "CCEaseElastic": if (currentInOutIndex == 0) { easing = new CCEaseElasticOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseElasticIn(coreAction); } else { easing = new CCEaseElasticInOut(coreAction); } break; case "CCEaseExponential": if (currentInOutIndex == 0) { easing = new CCEaseExponentialOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseExponentialIn(coreAction); } else { easing = new CCEaseExponentialInOut(coreAction); } break; case "CCEaseSine": if (currentInOutIndex == 0) { easing = new CCEaseSineOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseSineIn(coreAction); } else { easing = new CCEaseSineInOut(coreAction); } break; } if (easing != null) { nodeToAddTo.AddAction(easing); } else { nodeToAddTo.AddAction(coreAction); } }
public override void Stop(){ if (_action != null) { _view.stopAction(_action); _action = null; } }
public override void Play(MovieCallback callback){ if (callback == null) { Play(); return; } if (_startFrame == _endFrame) { GotoFrame(_startFrame); callback(this); return; } Stop (); GotoFrame (_startFrame); MovieImpAction action = new MovieImpAction (this, _startFrame, _endFrame); CCActionFiniteTime callbackAction = new CCCallBlock (delegate { callback(this); }); CCActionInterval seq = CCSequence.Actions (action, callbackAction) as CCActionInterval; if (_loop) { _action = new CCRepeatForever (seq); } else { _action = seq; } _view.runAction (_action); }
/** Executes an action, and returns the action that is executed. The node becomes the action's target. @warning Starting from v0.8 actions don't retain their target anymore. @since v0.7.1 @return An Action pointer */ public CCAction runAction(CCAction action){ NSUtils.Assert( action != null, "Argument must be non-nil"); _actionManager.addAction (action, this, !_isRunning); return action; }
public MovieImp(DefineMovie define) : base(define){ _startFrame = 0; _endFrame = _define.frames.Length - 1; _loop = true; _fps = define.flash.frameRate; _action = null; }