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


C# CCPoint.Normalize方法代码示例

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


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

示例1: ProcessGamePad

 private void ProcessGamePad(GamePadState gps, PlayerIndex player)
     {
     GamePadState lastState = new GamePadState();
     if (m_PriorGamePadState.ContainsKey(player))
         {
         lastState = m_PriorGamePadState[player];
         // Notify listeners when the gamepad is connected.
         if ((lastState.IsConnected != gps.IsConnected) && GamePadConnectionUpdate != null)
         {
             GamePadConnectionUpdate(player, false);
         }
         // TODO: Check button pressed/released status for button tap events.
     }
     if (gps.IsConnected)
     {
         GamePadCapabilities caps = GamePad.GetCapabilities(player);
         if (GamePadButtonUpdate != null)
         {
             CCGamePadButtonStatus back = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus start = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus system = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus a = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus b = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus x = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus y = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus leftShoulder = CCGamePadButtonStatus.NotApplicable;
             CCGamePadButtonStatus rightShoulder = CCGamePadButtonStatus.NotApplicable;
             if (caps.HasBackButton)
             {
                 back = (gps.Buttons.Back == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
         }
             if (caps.HasStartButton)
             {
                 start = (gps.Buttons.Start == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
     }
             if (caps.HasBigButton)
     {
                 system = (gps.Buttons.BigButton == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
             }
             if (caps.HasAButton)
         {
                 a = (gps.Buttons.A == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
         }
             if (caps.HasBButton)
             {
                 b = (gps.Buttons.B == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
     }
             if (caps.HasXButton)
     {
                 x = (gps.Buttons.X == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
             }
             if (caps.HasYButton)
         {
                 y = (gps.Buttons.Y == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
             }
             if (caps.HasLeftShoulderButton)
             {
                 leftShoulder = (gps.Buttons.LeftShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
             }
             if (caps.HasRightShoulderButton)
             {
                 rightShoulder = (gps.Buttons.RightShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released);
             }
             GamePadButtonUpdate(back, start, system, a, b, x, y, leftShoulder, rightShoulder, player);
         }
         // Process the game sticks
         if (GamePadStickUpdate != null && (caps.HasLeftXThumbStick || caps.HasLeftYThumbStick || caps.HasRightXThumbStick || caps.HasRightYThumbStick ||  caps.HasLeftStickButton || caps.HasRightStickButton))
         {
             CCPoint vecLeft;
             if (caps.HasLeftXThumbStick || caps.HasLeftYThumbStick)
             {
                 vecLeft = new CCPoint(gps.ThumbSticks.Left);
                 vecLeft.Normalize();
             }
             else
             {
                 vecLeft = CCPoint.Zero;
             }
             CCPoint vecRight;
             if (caps.HasRightXThumbStick || caps.HasRightYThumbStick)
             {
                 vecRight = new CCPoint(gps.ThumbSticks.Right);
                 vecRight.Normalize();
             }
             else
             {
                 vecRight = CCPoint.Zero;
             }
             CCGameStickStatus left = new CCGameStickStatus();
             left.Direction = vecLeft;
             left.Magnitude = ((caps.HasLeftXThumbStick || caps.HasLeftYThumbStick) ? gps.ThumbSticks.Left.Length() : 0f);
             left.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.LeftStick) : false);
             CCGameStickStatus right = new CCGameStickStatus();
             right.Direction = vecRight;
             right.Magnitude = ((caps.HasRightXThumbStick || caps.HasRightYThumbStick) ? gps.ThumbSticks.Right.Length() : 0f);
             right.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.RightStick) : false);
             GamePadStickUpdate(left, right, player);
         }
         // Process the game triggers
         if (GamePadTriggerUpdate != null && (caps.HasLeftTrigger || caps.HasRightTrigger))
//.........这里部分代码省略.........
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:101,代码来源:CCApplication.cs


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