当前位置: 首页>>代码示例>>C#>>正文


C# CCBReader.AddDocumentCallbackNode方法代码示例

本文整理汇总了C#中Cocos2D.CCBReader.AddDocumentCallbackNode方法的典型用法代码示例。如果您正苦于以下问题:C# CCBReader.AddDocumentCallbackNode方法的具体用法?C# CCBReader.AddDocumentCallbackNode怎么用?C# CCBReader.AddDocumentCallbackNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cocos2D.CCBReader的用法示例。


在下文中一共展示了CCBReader.AddDocumentCallbackNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParsePropTypeBlockCcControl

        protected virtual BlockCCControlData ParsePropTypeBlockCcControl(CCNode node, CCNode parent, CCBReader reader)
        {
            string selectorName = reader.ReadCachedString();
            var selectorTarget = (CCBTargetType) reader.ReadInt(false);
            var controlEvents = (CCControlEvent) reader.ReadInt(false);

            if (selectorTarget != CCBTargetType.None)
            {
                if (!reader.IsJSControlled())
                {
                    object target = null;
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        target = reader.AnimationManager.RootNode;
                    }
                    else if (selectorTarget == CCBTargetType.Owner)
                    {
                        target = reader.Owner;
                    }

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action<object, CCControlEvent> selCCControlHandler = null;

                            var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;
                            if (targetAsCCBSelectorResolver != null)
                            {
                                selCCControlHandler = targetAsCCBSelectorResolver.OnResolveCCBCCControlSelector(target,
                                                                                                                selectorName);
                            }
                            if (selCCControlHandler == null)
                            {
                                ICCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
                                if (ccbSelectorResolver != null)
                                {
                                    selCCControlHandler = ccbSelectorResolver.OnResolveCCBCCControlSelector(target,
                                                                                                            selectorName);
                                }
                            }

                            if (selCCControlHandler == null)
                            {
                                CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.",
                                          selectorName);
                            }
                            else
                            {
                                var blockCCControlData = new BlockCCControlData();
                                blockCCControlData.mSELCCControlHandler = selCCControlHandler;

                                blockCCControlData.mTarget = target;
                                blockCCControlData.mControlEvents = controlEvents;

                                return blockCCControlData;
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                    else
                    {
                        CCLog.Log("Unexpected NULL target for selector.");
                    }
                }
                else
                {
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        reader.AddDocumentCallbackNode(node);
                        reader.AddDocumentCallbackName(selectorName);

                    }
                    else
                    {
                        reader.AddOwnerCallbackNode(node);
                        reader.AddOwnerCallbackName(selectorName);
                    }
                }
            }

            return null;
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:86,代码来源:CCNodeLoader.cs

示例2: ParsePropTypeBlock

        protected virtual BlockData ParsePropTypeBlock(CCNode node, CCNode parent, CCBReader reader)
        {
            string selectorName = reader.ReadCachedString();
            var selectorTarget = (CCBTargetType) reader.ReadInt(false);

            if (selectorTarget != CCBTargetType.None)
            {
                object target = null;
                if (!reader.IsJSControlled())
                {
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        target = reader.AnimationManager.RootNode;
                    }
                    else if (selectorTarget == CCBTargetType.Owner)
                    {
                        target = reader.Owner;

                        /* Scripting specific code because selector function is common for all callbacks.
                         * So if we had 1 target and 1 selector function, the context (callback function name)
                         * would get lost. Hence the need for a new target for each callback.
                         */
                        if (reader._hasScriptingOwner)
                        {
                            var proxy = (ICCBScriptOwnerProtocol) reader.Owner;
                            if (proxy != null)
                            {
                                target = proxy.CreateNew() as object;
                            }
                        }
                    }

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action<object> selMenuHandler = null;

                            var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;

                            if (targetAsCCBSelectorResolver != null)
                            {
                                selMenuHandler = targetAsCCBSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
                                                                                                            selectorName);
                            }
                            if (selMenuHandler == null)
                            {
                                ICCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
                                if (ccbSelectorResolver != null)
                                {
                                    selMenuHandler = ccbSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
                                                                                                        selectorName);
                                }
                            }

                            if (selMenuHandler == null)
                            {
                                CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.",
                                          selectorName);
                            }
                            else
                            {
                                var blockData = new BlockData();
                                blockData.mSELMenuHandler = selMenuHandler;

                                blockData.mTarget = target;

                                return blockData;
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                    else
                    {
                        CCLog.Log("Unexpected NULL target for selector.");
                    }
                }
                else
                {
                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        reader.AddDocumentCallbackNode(node);
                        reader.AddDocumentCallbackName(selectorName);

                    }
                    else
                    {
                        reader.AddOwnerCallbackNode(node);
                        reader.AddOwnerCallbackName(selectorName);
                    }
                }
            }

            return null;
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:98,代码来源:CCNodeLoader.cs


注:本文中的Cocos2D.CCBReader.AddDocumentCallbackNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。