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


C# Stage.AddSprite方法代码示例

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


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

示例1: getBlockFromNode

        Block getBlockFromNode(XmlNode blockNode, Stage stage)
        {
            Vector2 location = parseAndScaleOrderedPairToVector2(blockNode.Attributes["location"].InnerText);
            Block block = new Block(location, BlockStateHelper.GetState(blockNode.Attributes["blockType"].InnerText), megaman, content);

            foreach (XmlNode itemNode in blockNode.ChildNodes)
            {
                try
                {
                    HiddenItem item = itemSpriteFactory.GetHiddenItem(itemNode.Attributes["itemType"].InnerText, block);
                    stage.AddSprite(item);
                    stage.AddCollidable(item);
                    block.AddItem(item);
                } catch (Exception)
                {
                    //Comment?
                }
            }

            return block;
        }
开发者ID:CtrlC-CtrlV,项目名称:megaman-mario,代码行数:21,代码来源:StageFactory.cs

示例2: getStageFromNode

        Stage getStageFromNode(XmlNode stageNode)
        {
            Vector2 boundary = parseAndScaleOrderedPairToVector2(stageNode.Attributes["boundary"].InnerText);
            Stage stage = new Stage(game, boundary,
                stageNode.Attributes["background"].InnerText,
                stageNode.Attributes["music"].InnerText,
                stageNode.Attributes["id"].InnerText);
            ControllerFactory controllerFactory = new ControllerFactory(stage, game, megaman);

            addBoundary(stage, boundary);

            foreach (XmlNode configItemNode in stageNode.ChildNodes)
            {
                if (configItemNode.Name == "block")
                {
                    Block block = getBlockFromNode(configItemNode, stage); // there's got to be a better way then passing the stage...
                    stage.AddSprite(block);
                    stage.AddCollidable(block);

                } else if (configItemNode.Name == "platform")
                {
                    Point platformDimensions = parseAndScaleOrderedPairToPoint(configItemNode.Attributes["size"].InnerText);
                    Vector2 platformLocation = parseAndScaleOrderedPairToVector2(configItemNode.Attributes["location"].InnerText);
                    BlockState platformType = BlockStateHelper.GetState(configItemNode.Attributes["blockType"].InnerText);

                    platformDimensions.X += (int)platformLocation.X;
                    platformDimensions.Y += (int)platformLocation.Y;

                    for (int i = (int)platformLocation.X; i < platformDimensions.X; i += 32)
                    {
                        for (int j = (int)platformLocation.Y; j < platformDimensions.Y; j += 32)
                        {
                            Block block = new Block(new Vector2(i, j), platformType, megaman, content);
                            stage.AddSprite(block);
                            stage.AddCollidable(block);
                        }
                    }

                } else if (configItemNode.Name == "item")
                {
                    Sprite item = getItemFromNode(configItemNode);
                    stage.AddSprite(item);
                    stage.AddCollidable(item);

                } else if (configItemNode.Name == "enemy")
                {
                    Sprite enemy = getEnemyFromNode(configItemNode);
                    stage.AddSprite(enemy);
                    stage.AddCollidable(enemy);

                } else if(configItemNode.Name == "megaman")
                {
                    stage.MegamanInitialPosition = parseAndScaleOrderedPairToVector2(configItemNode.Attributes["location"].InnerText);

                } else if (configItemNode.Name == "parallax")
                {
                    stage.AddSprite(getParallaxSpriteFromNode(configItemNode, stage));
                }
            }

            stage.Checkpoint = parseAndScaleOrderedPairToVector2(stageNode.Attributes["checkpoint"].InnerText);

            stage.AddSprite(new HUD(game.Content, game.Megaman, stage));
            stage.AddController(controllerFactory.GetGamePadController());
            stage.AddController(controllerFactory.GetKeyboardController());

            return stage;
        }
开发者ID:CtrlC-CtrlV,项目名称:megaman-mario,代码行数:68,代码来源:StageFactory.cs

示例3: addBoundary

        void addBoundary(Stage stage, Vector2 boundary)
        {
            for (int i = 0; i < boundary.X; i += 32)
            {
                Block topBlock = new Block(new Vector2(i, -31), BlockState.Pyramid, megaman, content);
                Block bottomBlock = new Block(new Vector2(i, boundary.Y), BlockState.Pyramid, megaman, content);

                stage.AddCollidable(topBlock);
                stage.AddCollidable(bottomBlock);
                stage.AddSprite(topBlock);
                stage.AddSprite(bottomBlock);
            }

            for (int i = 0; i < boundary.Y; i += 32)
            {
                Block leftBlock = new Block(new Vector2(-31, i), BlockState.Pyramid, megaman, content);
                Block rightBlock = new Block(new Vector2(boundary.X, i), BlockState.Pyramid, megaman, content);

                stage.AddCollidable(leftBlock);
                stage.AddCollidable(rightBlock);
                stage.AddSprite(leftBlock);
                stage.AddSprite(rightBlock);
            }
        }
开发者ID:CtrlC-CtrlV,项目名称:megaman-mario,代码行数:24,代码来源:StageFactory.cs


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