public bool initWithEntryID(int entryId) { // Register Touch Event touchListener = new CCEventListenerTouchOneByOne(); touchListener.IsSwallowTouches = true; touchListener.OnTouchBegan = onTouchBegan; touchListener.OnTouchMoved = onTouchMoved; touchListener.OnTouchEnded = onTouchEnded; AddEventListener(touchListener, -10); var keyboardListener = new CCEventListenerKeyboard (); keyboardListener.OnKeyPressed = onKeyPressed; keyboardListener.OnKeyReleased = onKeyReleased; AddEventListener(keyboardListener); m_entry = TestEntries.TestList[entryId]; m_test = m_entry.CreateFcn(); return true; }
public bool AttachWithIME() { if (IsXAML) { return(ShowKeyboardInput()); } else { if (TextFieldInFocus != null) { OnKeyboardWillShow(); IsVisible = true; OnKeyboardDidShow(); AutoRepeat = TextFieldInFocus.AutoRepeat; keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = OnKeyPressed; keyboardListener.OnKeyReleased = OnKeyReleased; TextFieldInFocus.AddEventListener(keyboardListener); return(true); } } return(false); }
public MenuScene(CCWindow window) : base(window) { SceneResolutionPolicy = CCSceneResolutionPolicy.ShowAll; _backgroundLayer = new MenuBackgroundLayer(); AddChild(_backgroundLayer); _menuLayer = new MenuLayer(); AddChild(_menuLayer); var keyListener = new CCEventListenerKeyboard {OnKeyReleased = OnKeyReleased}; AddEventListener(keyListener, this); }
public bool AttachWithIME() { ShowKeyboardInput(ContentText); if (true) { if (TextFieldInFocus != null) { AutoRepeat = TextFieldInFocus.AutoRepeat; keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = OnKeyPressed; keyboardListener.OnKeyReleased = OnKeyReleased; TextFieldInFocus.AddEventListener(keyboardListener); } } return(true); }
public bool AttachWithIME() { ShowKeyboardInput(ContentText); if (true) { if (TextFieldInFocus != null) { AutoRepeat = TextFieldInFocus.AutoRepeat; keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = OnKeyPressed; keyboardListener.OnKeyReleased = OnKeyReleased; TextFieldInFocus.AddEventListener(keyboardListener); } } return true; }
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); }
protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets var bounds = VisibleBoundsWorldspace; mid = CCSimpleAudioEngine.SharedEngine.PlayEffect("bgm/bgm2", true); fondo.Position = bounds.Center; label.Position = bounds.Center; GameData.ResizeBackground(fondo, this); //TODO hallar el centro de la pantalla CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/coin", false); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); var keyListener = new CCEventListenerKeyboard(); touchListener.OnTouchesEnded = OnTouchesEnded; keyListener.OnKeyPressed = OnKeyPress; AddEventListener(touchListener, this); AddEventListener(keyListener, this); }
protected override void AddedToScene() { base.AddedToScene(); CCSimpleAudioEngine.SharedEngine.PlayEffect(musicMapa, true); var Bounds = VisibleBoundsWorldspace; fondo.Position = Bounds.Center; GameData.ResizeBackground(fondo, this); GameData.ResizeSprite(piloto, 0.7f); piloto.Position = new CCPoint(50, 100); texto.Position = new CCPoint(200, 500); for(int i=0; i< GameData.players; i++) { jugadores[i].Position = GameData.getPointMapa(GameData.pos[i], this); } //Agrego listener var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); CCEventListenerKeyboard keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = onKeyPress; AddEventListener(keyboardListener, this); }
private void InitializeKeyboardListener() { CCEventListenerKeyboard keyListener = new CCEventListenerKeyboard(); keyListener.OnKeyReleased = KeyReleased; AddEventListener(keyListener, this); }
protected override void AddedToScene() { base.AddedToScene(); CCSize tamaño = Scene.Window.WindowSizeInPixels; CCSimpleAudioEngine.SharedEngine.StopEffect(musicId); CCSimpleAudioEngine.SharedEngine.PlayEffect(soundMSG); // Use the bounds to layout the positioning of our drawable assets var bounds = VisibleBoundsWorldspace; fondo.Position = bounds.Center; // position the label on the center of the screen label.Color = CCColor3B.Black; label.Position = bounds.Center; p1button.Position = GetPosicionJugador(1); p2button.Position = GetPosicionJugador(2); p3button.Position = GetPosicionJugador(3); p4button.Position = GetPosicionJugador(4); GameData.ResizeBackground(fondo, this); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); CCEventListenerKeyboard keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = onKeyPress; touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); AddEventListener(keyboardListener, this); }
public void InitializeKeyboard() { KeyListener = new CCEventListenerKeyboard(); KeyListener.OnKeyPressed = OnKeyPressed; KeyListener.OnKeyReleased = OnKeyReleased; }
protected override void AddedToScene() { base.AddedToScene(); var Bounds = VisibleBoundsWorldspace; debug.Color = CCColor3B.Black; debug.Position = Bounds.Center; fondo.Position = Bounds.Center; GameData.ResizeBackground(fondo, this); for(int i=0; i<botones.Length; i++) { botones[i].Position = GetPosicionJugador(i+1); } //Agrego listener var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); CCEventListenerKeyboard keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = onKeyPress; AddEventListener(keyboardListener, this); Schedule(Update); }
public override void OnEnter () { base.OnEnter (); var origin = Layer.VisibleBoundsWorldspace.Origin; var size = Layer.VisibleBoundsWorldspace.Size; var statusLabel = new CCLabelTtf("No keyboard event received!", "arial", 20); statusLabel.Position = origin + size.Center; AddChild(statusLabel); // Create our Keyboard Listener var listener = new CCEventListenerKeyboard(); // We will use Lambda expressions to attach the event process listener.OnKeyPressed = (keyboardEvent) => { var labelText = string.Format("Key {0} was pressed.", keyboardEvent.Keys); statusLabel.Text = labelText; }; listener.OnKeyReleased = (keyboardEvent) => { var labelText = string.Format("Key {0} was released.", keyboardEvent.Keys); statusLabel.Text = labelText; }; // Now we tell the event dispatcher that the status label is interested in keyboard events statusLabel.AddEventListener(listener); }
public SpineBoyLayer() { labelBones = new CCLabelTtf("B = Toggle Debug Bones", "arial", 12); labelBones.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelBones); labelSlots = new CCLabelTtf("M = Toggle Debug Slots", "arial", 12); labelSlots.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelSlots); labelTimeScale = new CCLabelTtf("Up/Down = TimeScale +/-", "arial", 12); labelTimeScale.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelTimeScale); labelScene = new CCLabelTtf("G = Goblins", "arial", 12); labelScene.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelScene); labelJump = new CCLabelTtf("J = Jump", "arial", 12); labelJump.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelJump); String name = @"spineboy"; skeletonNode = new CCSkeletonAnimation(name + ".json", name + ".atlas", 0.25f); skeletonNode.SetMix("walk", "jump", 0.2f); skeletonNode.SetMix("jump", "run", 0.2f); skeletonNode.SetAnimation(0, "walk", true); TrackEntry jumpEntry = skeletonNode.AddAnimation(0, "jump", false, 3); skeletonNode.AddAnimation(0, "run", true); skeletonNode.Start += Start; skeletonNode.End += End; skeletonNode.Complete += Complete; skeletonNode.Event += Event; AddChild(skeletonNode); var listener = new CCEventListenerTouchOneByOne(); listener.OnTouchBegan = (touch, touchEvent) => { if (!skeletonNode.DebugBones) { skeletonNode.DebugBones = true; } else if (skeletonNode.TimeScale == 1) skeletonNode.TimeScale = 0.3f; return true; }; AddEventListener(listener, this); var keyListener = new CCEventListenerKeyboard(); keyListener.OnKeyPressed = (keyEvent) => { switch (keyEvent.Keys) { case CCKeys.B: skeletonNode.DebugBones = !skeletonNode.DebugBones; break; case CCKeys.M: skeletonNode.DebugSlots = !skeletonNode.DebugSlots; break; case CCKeys.Up: skeletonNode.TimeScale += 0.1f; break; case CCKeys.Down: skeletonNode.TimeScale -= 0.1f; break; case CCKeys.G: Director.ReplaceScene(GoblinLayer.Scene); break; case CCKeys.J: // I truthfully do not know if this is how it is done or not skeletonNode.SetAnimation(0, "jump", false); skeletonNode.AddAnimation(0, "run", true); break; } }; AddEventListener(keyListener, this); }
internal CCEventListenerKeyboard(CCEventListenerKeyboard keyboard) : this() { OnKeyPressed = keyboard.OnKeyPressed; OnKeyReleased = keyboard.OnKeyReleased; }
public StopPropagationTest() : base() { var touchOneByOneListener = new CCEventListenerTouchOneByOne(); touchOneByOneListener.IsSwallowTouches = true; touchOneByOneListener.OnTouchBegan = (touch, touchEvent) => { // Skip if don't touch top half screen. if (!IsPointInTopHalfAreaOfScreen(touch.LocationOnScreen)) return false; var target = (CCSprite)touchEvent.CurrentTarget; Debug.Assert (target.Tag == TAG_BLUE_SPRITE, "Yellow blocks shouldn't response event."); if (IsPointInNode(touch.LocationOnScreen, target)) { target.Opacity = 180; return true; } // Stop propagation, so yellow blocks will not be able to receive event. touchEvent.StopPropogation(); return false; }; touchOneByOneListener.OnTouchEnded = (touch, touchEvent) => { var target = (CCSprite)touchEvent.CurrentTarget; target.Opacity = 255; }; var touchAllAtOnceListener = new CCEventListenerTouchAllAtOnce(); touchAllAtOnceListener.OnTouchesBegan = (touches, touchEvent) => { // Skip if don't touch top half screen. if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen)) return; var target = (CCSprite)touchEvent.CurrentTarget; Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event."); if (IsPointInNode(touches[0].LocationOnScreen, target)) { target.Opacity = 180; } // Stop propagation, so yellow blocks will not be able to receive event. touchEvent.StopPropogation(); }; touchAllAtOnceListener.OnTouchesEnded = (touches, touchEvent) => { // Skip if don't touch top half screen. if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen)) return; var target = (CCSprite)touchEvent.CurrentTarget; Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event."); if (IsPointInNode(touches[0].LocationOnScreen, target)) { target.Opacity = 255;; } // Stop propagation, so yellow blocks will not be able to receive event. touchEvent.StopPropogation(); }; var keyboardEventListener = new CCEventListenerKeyboard(); keyboardEventListener.OnKeyPressed = (keyboardEvent) => { var target = (CCSprite)keyboardEvent.CurrentTarget; Debug.Assert(target.Tag == TAG_BLUE_SPRITE || target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event."); // Stop propagation, so yellow blocks will not be able to receive event. keyboardEvent.StopPropogation(); }; const int SPRITE_COUNT = 8; for (int i = 0; i < SPRITE_COUNT; i++) { CCSprite sprite; CCSprite sprite2; if(i==4) { sprite = new CCSprite("Images/CyanSquare.png"); sprite.Tag = TAG_BLUE_SPRITE; AddChild(sprite, 100); sprite2 = new CCSprite("Images/CyanSquare.png"); sprite2.Tag = TAG_BLUE_SPRITE2; AddChild(sprite2, 100); } else { sprite = new CCSprite("Images/YellowSquare.png"); AddChild(sprite, 0); sprite2 = new CCSprite("Images/YellowSquare.png"); AddChild(sprite2, 0); } sprite.AddEventListener(touchOneByOneListener.Copy()); sprite.AddEventListener(keyboardEventListener.Copy()); sprite2.AddEventListener(touchAllAtOnceListener.Copy()); sprite2.AddEventListener(keyboardEventListener.Copy()); var visibleBounds = Layer.VisibleBoundsWorldspace; sprite.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y + sprite2.ContentSize.Height/2 +10); sprite2.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y - sprite2.ContentSize.Height/2-10); } }
protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets var bounds = VisibleBoundsWorldspace; mid=CCSimpleAudioEngine.SharedEngine.PlayEffect("bgm/title",true); // position the label on the center of the screen label.Position = bounds.Center; fondo.Position = bounds.Center; GameData.ResizeBackground(fondo, this); azafata.Position = new CCPoint(200, 200); //Ubicar las 6 sillas al inicio twoplayerlabels.Position = new CCPoint(500, 250); threeplayerlabel.Position = new CCPoint(400, 100); fourplayerLabel.Position = new CCPoint(600, 100); //TODO hallar el centro de la pantalla CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/coin",false); // Register for touch events var touchListener = new CCEventListenerTouchAllAtOnce(); var keyListener = new CCEventListenerKeyboard(); touchListener.OnTouchesEnded = OnTouchesEnded; keyListener.OnKeyPressed = OnKeyPress; AddEventListener(touchListener, this); AddEventListener(keyListener, this); }
public GoblinLayer() { labelBones = new CCLabelTtf("B = Toggle Debug Bones", "arial", 12); labelBones.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelBones); labelSlots = new CCLabelTtf("M = Toggle Debug Slots", "arial", 12); labelSlots.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelSlots); labelSkin = new CCLabelTtf("S = Toggle Skin", "arial", 12); labelSkin.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelSkin); labelTimeScale = new CCLabelTtf("Up/Down = TimeScale +/-", "arial", 12); labelTimeScale.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelTimeScale); labelAction = new CCLabelTtf("A = Toggle Move Action", "arial", 12); labelAction.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelAction); labelScene = new CCLabelTtf("P = SpineBoy", "arial", 12); labelScene.AnchorPoint = CCPoint.AnchorMiddleLeft; AddChild(labelScene); String name = @"goblins-ffd"; //String name = @"goblins"; skeletonNode = new CCSkeletonAnimation(name + ".json", name + ".atlas", 0.5f); skeletonNode.PremultipliedAlpha = true; skeletonNode.SetSkin("goblin"); var wt = skeletonNode.NodeToWorldTransform; skeletonNode.SetSlotsToSetupPose(); skeletonNode.UpdateWorldTransform(); skeletonNode.AddAnimation(0, "walk", true, 4); skeletonNode.SetAnimation(0, "walk", true); skeletonNode.Start += Start; skeletonNode.End += End; skeletonNode.Complete += Complete; skeletonNode.Event += Event; //skeletonNode.RepeatForever(new CCFadeOut(1), new CCFadeIn(1)); AddChild(skeletonNode); var listener = new CCEventListenerTouchOneByOne(); listener.OnTouchBegan = (touch, touchEvent) => { if (!skeletonNode.DebugBones) { skeletonNode.DebugBones = true; } else if (skeletonNode.TimeScale == 1) skeletonNode.TimeScale = 0.3f; else if (skeletonNode.Skeleton.Skin.Name == "goblin") skeletonNode.SetSkin("goblingirl"); return true; }; AddEventListener(listener, this); var keyListener = new CCEventListenerKeyboard(); keyListener.OnKeyPressed = (keyEvent) => { switch (keyEvent.Keys) { case CCKeys.B: skeletonNode.DebugBones = !skeletonNode.DebugBones; break; case CCKeys.M: skeletonNode.DebugSlots = !skeletonNode.DebugSlots; break; case CCKeys.S: if (skeletonNode.Skeleton.Skin.Name == "goblin") skeletonNode.SetSkin("goblingirl"); else skeletonNode.SetSkin("goblin"); break; case CCKeys.Up: skeletonNode.TimeScale += 0.1f; break; case CCKeys.Down: skeletonNode.TimeScale -= 0.1f; break; case CCKeys.A: if (isMoving) { StopAction(skeletonActionState); isMoving = false; } else { skeletonActionState = skeletonNode.RepeatForever(skeletonMoveAction); isMoving = true; } break; case CCKeys.P: Director.ReplaceScene(SpineBoyLayer.Scene); break; } }; AddEventListener(keyListener, this); }
public bool AttachWithIME() { if (IsXAML) { return ShowKeyboardInput(); } else { if (TextFieldInFocus != null) { OnKeyboardWillShow(); IsVisible = true; OnKeyboardDidShow(); AutoRepeat = TextFieldInFocus.AutoRepeat; keyboardListener = new CCEventListenerKeyboard(); keyboardListener.OnKeyPressed = OnKeyPressed; keyboardListener.OnKeyReleased = OnKeyReleased; TextFieldInFocus.AddEventListener(keyboardListener); return true; } } return false; }
public SpineBoyLayer() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 12; labelBones = new CCMenuItemFont("B = Toggle Debug Bones", (obj) => { skeletonNode.DebugBones = !skeletonNode.DebugBones; } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; labelSlots = new CCMenuItemFont("M = Toggle Debug Slots", (obj) => { skeletonNode.DebugSlots = !skeletonNode.DebugSlots; } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; labelTimeScaleUp = new CCMenuItemFont("Up - TimeScale +", (obj) => { skeletonNode.TimeScale += 0.1f; } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; labelTimeScaleDown = new CCMenuItemFont("Down - TimeScale -", (obj) => { skeletonNode.TimeScale -= 0.1f; } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; labelScene = new CCMenuItemFont("G = Goblins", (obj) => { Director.ReplaceScene(GoblinLayer.Scene(Window)); } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; labelJump = new CCMenuItemFont("J = Jump", (obj) => { // I truthfully do not know if this is how it is done or not skeletonNode.SetAnimation(0, "jump", false); skeletonNode.AddAnimation(0, "run", true); } ) { AnchorPoint = CCPoint.AnchorMiddleLeft }; menu = new CCMenu(labelBones, labelSlots, labelTimeScaleUp, labelTimeScaleDown, labelJump, labelScene); menu.AlignItemsVertically(); AddChild(menu); String name = @"spineboy"; skeletonNode = new CCSkeletonAnimation(name + ".json", name + ".atlas", 0.25f); skeletonNode.SetMix("walk", "jump", 0.2f); skeletonNode.SetMix("jump", "run", 0.2f); skeletonNode.SetAnimation(0, "walk", true); TrackEntry jumpEntry = skeletonNode.AddAnimation(0, "jump", false, 3); skeletonNode.AddAnimation(0, "run", true); skeletonNode.Start += Start; skeletonNode.End += End; skeletonNode.Complete += Complete; skeletonNode.Event += Event; AddChild(skeletonNode); var listener = new CCEventListenerTouchOneByOne(); listener.OnTouchBegan = (touch, touchEvent) => { if (!skeletonNode.DebugBones) { skeletonNode.DebugBones = true; } else if (skeletonNode.TimeScale == 1) skeletonNode.TimeScale = 0.3f; return true; }; AddEventListener(listener, this); var keyListener = new CCEventListenerKeyboard(); keyListener.OnKeyPressed = (keyEvent) => { switch (keyEvent.Keys) { case CCKeys.B: skeletonNode.DebugBones = !skeletonNode.DebugBones; break; case CCKeys.M: skeletonNode.DebugSlots = !skeletonNode.DebugSlots; break; case CCKeys.Up: skeletonNode.TimeScale += 0.1f; break; case CCKeys.Down: skeletonNode.TimeScale -= 0.1f; break; case CCKeys.G: Director.ReplaceScene(GoblinLayer.Scene(Window)); break; case CCKeys.J: // I truthfully do not know if this is how it is done or not skeletonNode.SetAnimation(0, "jump", false); skeletonNode.AddAnimation(0, "run", true); break; } }; AddEventListener(keyListener, this); }