コード例 #1
0
ファイル: RubeBasicLayer.cs プロジェクト: netonjm/RubeLoader
        public RubeBasicLayer(string jsonfile)
        {
            AnchorPoint = new CCPoint(0, 0);

            HasWheel = true;

            JSON_FILE = jsonfile;

            TouchPanel.EnabledGestures = GestureType.Pinch | GestureType.PinchComplete;

            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesBegan = OnTouchesBegan;
            touchListener.OnTouchesMoved = OnTouchesMoved;
            touchListener.OnTouchesEnded = OnTouchesEnded;
            touchListener.OnTouchesCancelled = OnTouchesCancelled;
            AddEventListener(touchListener, this);

            var mouseListener = new CCEventListenerMouse();
            mouseListener.OnMouseScroll = OnMouseScroll;
            AddEventListener(mouseListener, this);

            // set the starting scale and offset values from the subclass
            Position = InitialWorldOffset();
            Scale = InitialWorldScale();

            // load the world from RUBE .json file (this will also call afterLoadProcessing)
            LoadWorld();
        }
コード例 #2
0
 internal CCEventListenerMouse(CCEventListenerMouse mouse)
     : this()
 {
     OnMouseDown   = mouse.OnMouseDown;
     OnMouseMove   = mouse.OnMouseMove;
     OnMouseUp     = mouse.OnMouseUp;
     OnMouseScroll = mouse.OnMouseScroll;
 }
コード例 #3
0
		internal CCEventListenerMouse(CCEventListenerMouse mouse)
			: this()
		{
			OnMouseDown = mouse.OnMouseDown;
			OnMouseMove = mouse.OnMouseMove;
			OnMouseUp = mouse.OnMouseUp;
			OnMouseScroll = mouse.OnMouseScroll;
		}
コード例 #4
0
        public GameScene(CCWindow window) : base(window) {
            Id = "";

            _backgroundLayer = new BackgroundLayer();
            AddChild(_backgroundLayer);

            var cameraVisibleBounds = new CCSize(Settings.ScreenWidth, Settings.ScreenHeight);
            var camera = new CCCamera(CCCameraProjection.Projection3D, cameraVisibleBounds,
                new CCPoint3(Settings.ScreenWidth, Settings.ScreenHeight, 10));

            GameLayer = new GameLayer {
                Tag = Tags.Client,
                Camera = camera,
            };
            AddChild(GameLayer);

            _chatLayer = new ChatLayer();
            AddChild(_chatLayer);

            _hudLayer = new HudLayer();
            AddChild(_hudLayer);


            var keyListener = new CCEventListenerKeyboard {OnKeyPressed = OnKeyPressed, OnKeyReleased = OnKeyReleased};
            AddEventListener(keyListener, this);

            var mouseListener = new CCEventListenerMouse {
                OnMouseDown = OnMouseDown,
                OnMouseUp = OnMouseUp,
                OnMouseMove = OnMouseScroll
            };
            AddEventListener(mouseListener, this);

            var parser = new FileIniDataParser();
            IniData data = parser.ReadFile("Config.ini");
            string nickname = data["Client"]["nickname"];
            _netGameClient = new NetGameClient(data["Server"]["ip"], this);
            _netGameClient.ConnectToServer(nickname);

            InitEvents();

            Schedule(Update);
            Schedule(UpdateNetwork, Settings.NetworkFreqUpdate);
        }
コード例 #5
0
ファイル: controller.cs プロジェクト: h7ing/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter(); 
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

            // Laying out content based on window size
            closeMenu.Position = CCPoint.Zero;
            closeMenuItem.Position = new CCPoint(visibleBounds.Size.Width - 40, visibleBounds.Size.Height - 40);

#if !PSM && !WINDOWS_PHONE

            versionLabel.HorizontalAlignment = CCTextAlignment.Left;
            versionLabel.Position = new CCPoint (10.0f, visibleBounds.Size.Height - 40);
#endif
            testListMenu.ContentSize = new CCSize(visibleBounds.Size.Width, ((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE);

            int i = 0;
            foreach (CCMenuItem testItem in testListMenuItems) 
            {
                testItem.Position = new CCPoint(visibleBounds.Size.Width /2.0f, (visibleBounds.Size.Height - (i + 1) * LINE_SPACE));

                i++;
            }
                
            #if XBOX || OUYA
            // Center the menu on the first item so that it is 
            // in the center of the screen
            homePosition = new CCPoint(0f, visibleBounds.Size.Height / 2f + LINE_SPACE / 2f);
            lastPosition = new CCPoint(0f, homePosition.Y - (testListMenuItems.Count - 1) * LINE_SPACE);
            #else
			homePosition = curPos;
            #endif

            testListMenu.Position = homePosition;

            // Add listeners
            #if !XBOX && !OUYA
            var touchListener = new CCEventListenerTouchOneByOne ();
            touchListener.IsSwallowTouches = true;
            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;

            AddEventListener(touchListener);

            var mouseListener = new CCEventListenerMouse ();
            mouseListener.OnMouseScroll = OnMouseScroll;
            AddEventListener(mouseListener);

            #endif

            #if WINDOWS || WINDOWSGL || MACOS
            EnableGamePad();
            #endif

            // set the first one to have the selection highlight
            currentItemIndex = 0;
            //SelectMenuItem();
        }
コード例 #6
0
		public override void OnEnter ()
		{
            CCRect visibleBounds = VisibleBoundsWorldspace;

            base.OnEnter ();

            int line = (int)(visibleBounds.Size.Height / 2);

			mousePosition = new CCLabelTtf ("Mouse Position: ", "arial", 20);
            mousePosition.Position = new CCPoint (130, line + 60);
			mousePosition.AnchorPoint = CCPoint.AnchorMiddleLeft;
			AddChild (mousePosition);

			mouseButtonDown = new CCLabelTtf ("Mouse Button Down: ", "arial", 20);
            mouseButtonDown.Position = new CCPoint (130, line + 20);
			mouseButtonDown.AnchorPoint = CCPoint.AnchorMiddleLeft;
			AddChild (mouseButtonDown);

			mouseButtonUp = new CCLabelTtf ("Mouse Button Up: ", "arial", 20);
            mouseButtonUp.Position = new CCPoint (130, line - 20);
			mouseButtonUp.AnchorPoint = CCPoint.AnchorMiddleLeft;
			AddChild (mouseButtonUp);

			scrollWheel = new CCLabelTtf ("Scroll Wheel Delta: ", "arial", 20);
            scrollWheel.Position = new CCPoint (130, line - 60);
			scrollWheel.AnchorPoint = CCPoint.AnchorMiddleLeft;
			AddChild (scrollWheel);


			var mouseListener = new CCEventListenerMouse();
			mouseListener.OnMouseScroll = OnMouseScroll;
			mouseListener.OnMouseDown = OnMouseDown;
			mouseListener.OnMouseUp = OnMouseUp;
			mouseListener.OnMouseMove = OnMouseMove;
            AddEventListener(mouseListener);
		}