public override void OnEnter() { base.OnEnter(); // Disable events while transitioning EventDispatcherIsEnabled = false; // OutScene should not receive the OnEnter callback // only the OnExitTransitionDidStart OutScene.OnExitTransitionDidStart(); InScene.OnEnter(); InitialiseScenes(); if (InSceneAction != null) { InSceneNodeContainer.RunAction(InSceneAction); } if (OutSceneAction != null) { OutSceneNodeContainer.RunAction(new CCSequence(OutSceneAction, new CCCallFunc(Finish))); } else { OutSceneNodeContainer.RunAction(new CCSequence(new CCDelayTime(Duration), new CCCallFunc(Finish))); } }
public override void OnEnter() { base.OnEnter(); // Disable events while transitioning EventDispatcherIsEnabled = false; InScene.OnEnter(); InitialiseScenes(); OutSceneNodeContainer.OnEnter(); InSceneNodeContainer.OnEnter(); if (InSceneAction != null) { InSceneNodeContainer.RunAction(InSceneAction); } if (OutSceneAction != null) { OutSceneNodeContainer.RunAction(new CCSequence(OutSceneAction, new CCCallFunc(Finish))); } else { OutSceneNodeContainer.RunAction(new CCSequence(new CCDelayTime(Duration), new CCCallFunc(Finish))); } }
protected override void InitialiseScenes() { base.InitialiseScenes(); var bounds = Layer.VisibleBoundsWorldspace; CCRect viewportRect = Viewport.ViewportInPixels; CCRenderTexture outTexture = new CCRenderTexture(bounds.Size, viewportRect.Size); CCSprite outTexSprite = outTexture.Sprite; var worldTransform = Layer.AffineWorldTransform; outTexture.BeginWithClear(0, 0, 0, 0); OutSceneNodeContainer.Visit(ref worldTransform); outTexture.End(); outTexSprite.AnchorPoint = CCPoint.AnchorMiddle; outTexSprite.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2); outTexSprite.BlendFunc = CCBlendFunc.NonPremultiplied; outTexSprite.Opacity = 255; CCAction layerAction = new CCSequence(new CCFadeTo(Duration, 0), new CCCallFunc((Finish))); outTexSprite.RunAction(layerAction); Layer.AddChild(outTexture.Sprite, 3); InSceneNodeContainer.Visible = true; OutSceneNodeContainer.Visible = false; }
protected override void InitialiseScenes() { base.InitialiseScenes(); // create a transparent color layer // in which we are going to add our rendertextures var color = new CCColor4B(0, 0, 0, 0); var bounds = Layer.VisibleBoundsWorldspace; CCRect viewportRect = Viewport.ViewportInPixels; // create the first render texture for inScene CCRenderTexture inTexture = new CCRenderTexture(bounds.Size, viewportRect.Size); if (null == inTexture) { return; } inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); inTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2); inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(inTexture); // render inScene to its texturebuffer inTexture.Begin(); InSceneNodeContainer.Visit(); inTexture.End(); // create the second render texture for outScene CCRenderTexture outTexture = new CCRenderTexture(bounds.Size, viewportRect.Size); outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); outTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2); outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(outTexture); // render outScene to its texturebuffer outTexture.Begin(); OutSceneNodeContainer.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 inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; CCAction layerAction = new CCSequence ( new CCFadeTo(Duration, 0), new CCCallFunc((Finish)) ); outTexture.Sprite.RunAction(layerAction); InSceneNodeContainer.Visible = false; OutSceneNodeContainer.Visible = false; }