public void openTest(string pCCBFileName, string pCCNodeName, CCNodeLoader pCCNodeLoader) { /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary ccNodeLoaderLibrary = CCNodeLoaderLibrary.NewDefaultCCNodeLoaderLibrary(); ccNodeLoaderLibrary.RegisterCCNodeLoader("TestHeaderLayer", new Loader<TestHeaderLayer>()); if (pCCNodeName != null && pCCNodeLoader != null) { ccNodeLoaderLibrary.RegisterCCNodeLoader(pCCNodeName, pCCNodeLoader); } /* Create an autorelease CCBReader. */ var ccbReader = new CCBReader(ccNodeLoaderLibrary); /* Read a ccbi file. */ // Load the scene from the ccbi-file, setting this class as // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. CCNode node = ccbReader.ReadNodeGraphFromFile(pCCBFileName, this); mTestTitleLabelTTF.Label = (pCCBFileName); CCScene scene = new CCScene(); scene.AddChild(node); /* Push the new scene with a fancy transition. */ CCColor3B transitionColor; transitionColor.R = 0; transitionColor.G = 0; transitionColor.B = 0; CCDirector.SharedDirector.PushScene(new CCTransitionFade(0.5f, scene, transitionColor)); }
private CCNode ReadNodeGraph(CCNode parent) { /* Read class name. */ string className = ReadCachedString(); // Read assignment type and name var memberVarAssignmentType = (CCBTargetType)ReadInt(false); string memberVarAssignmentName = String.Empty; if (memberVarAssignmentType != CCBTargetType.None) { memberVarAssignmentName = ReadCachedString(); } CCNodeLoader ccNodeLoader = mCCNodeLoaderLibrary.GetCCNodeLoader(className); if (ccNodeLoader == null) { CCLog.Log("no corresponding node loader for {0}", className); return(null); } CCNode node = ccNodeLoader.LoadCCNode(parent, this); // Set root node if (mActionManager.RootNode == null) { mActionManager.RootNode = node; } // Read animated properties var seqs = new Dictionary <int, Dictionary <string, CCBSequenceProperty> >(); mAnimatedProps.Clear(); int numSequence = ReadInt(false); for (int i = 0; i < numSequence; ++i) { int seqId = ReadInt(false); var seqNodeProps = new Dictionary <string, CCBSequenceProperty>(); int numProps = ReadInt(false); for (int j = 0; j < numProps; ++j) { var seqProp = new CCBSequenceProperty(); seqProp.Name = ReadCachedString(); seqProp.Type = (CCBPropType)ReadInt(false); mAnimatedProps.Add(seqProp.Name); int numKeyframes = ReadInt(false); for (int k = 0; k < numKeyframes; ++k) { CCBKeyframe keyframe = ReadKeyframe(seqProp.Type); seqProp.Keyframes.Add(keyframe); } seqNodeProps.Add(seqProp.Name, seqProp); } seqs.Add(seqId, seqNodeProps); } if (seqs.Count > 0) { mActionManager.AddNode(node, seqs); } // Read properties ccNodeLoader.ParseProperties(node, parent, this); // Handle sub ccb files (remove middle node) if (node is CCBFile) { var ccbFileNode = (CCBFile)node; CCNode embeddedNode = ccbFileNode.FileNode; embeddedNode.Position = ccbFileNode.Position; embeddedNode.Rotation = ccbFileNode.Rotation; embeddedNode.Scale = ccbFileNode.Scale; embeddedNode.Tag = ccbFileNode.Tag; embeddedNode.Visible = true; embeddedNode.IgnoreAnchorPointForPosition = ccbFileNode.IgnoreAnchorPointForPosition; ccbFileNode.FileNode = null; node = embeddedNode; } #if CCB_ENABLE_JAVASCRIPT /* * if (memberVarAssignmentType && memberVarAssignmentName && ![memberVarAssignmentName isEqualToString:@""]) * { * [[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName]; * }*/ #else if (memberVarAssignmentType != CCBTargetType.None) { object target = null; if (memberVarAssignmentType == CCBTargetType.DocumentRoot) { target = mActionManager.RootNode; } else if (memberVarAssignmentType == CCBTargetType.Owner) { target = mOwner; } if (target != null) { bool assigned = false; var targetAsCCBMemberVariableAssigner = (ICCBMemberVariableAssigner)target; if (targetAsCCBMemberVariableAssigner != null) { assigned = targetAsCCBMemberVariableAssigner.OnAssignCCBMemberVariable(target, memberVarAssignmentName, node); } if (!assigned && mCCBMemberVariableAssigner != null) { mCCBMemberVariableAssigner.OnAssignCCBMemberVariable(target, memberVarAssignmentName, node); } } } #endif // CCB_ENABLE_JAVASCRIPT mAnimatedProps.Clear(); /* Read and add children. */ int numChildren = ReadInt(false); for (int i = 0; i < numChildren; i++) { CCNode child = ReadNodeGraph(node); node.AddChild(child); } // Call onNodeLoaded var nodeAsCCNodeLoaderListener = node as ICCNodeLoaderListener; if (nodeAsCCNodeLoaderListener != null) { nodeAsCCNodeLoaderListener.OnNodeLoaded(node, ccNodeLoader); } else if (mCCNodeLoaderListener != null) { mCCNodeLoaderListener.OnNodeLoaded(node, ccNodeLoader); } return(node); }
public override void OnNodeLoaded(CCNode node, CCNodeLoader nodeLoader) { CCRotateBy ccRotateBy = new CCRotateBy (20.0f, 360); CCRepeatForever ccRepeatForever = new CCRepeatForever (ccRotateBy); mBurstSprite.RunAction(ccRepeatForever); }
public void RegisterCCNodeLoader(string pClassName, CCNodeLoader pCCNodeLoader) { _nodeLoaders.Add(pClassName, pCCNodeLoader); }
public void RegisterCCNodeLoader(string pClassName, CCNodeLoader pCCNodeLoader) { mCCNodeLoaders.Add(pClassName, pCCNodeLoader); }