void onTouchMoved(CCTouch touch, CCEvent touchEvent) { CCPoint touchLocation = touch.Location; CCPoint nodePosition = ConvertToNodeSpace(touchLocation); m_test.MouseMove(new Vector2(nodePosition.X, nodePosition.Y)); }
void onTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { //base.ccTouchesEnded(touches, event_); object it = touches.First(); CCTouch touch = (CCTouch)(it); var convertedLocation = touch.Location; CCNode s = this[ClickAndMoveTest.kTagSprite]; s.StopAllActions(); s.RunAction(new CCMoveTo (1, new CCPoint(convertedLocation.X, convertedLocation.Y))); float o = convertedLocation.X - s.Position.X; float a = convertedLocation.Y - s.Position.Y; float at = (float)(Math.Atan(o / a) * 57.29577951f); if (a < 0) { if (o < 0) at = 180 + Math.Abs(at); else at = 180 - Math.Abs(at); } s.RunAction(new CCRotateTo (1, at)); }
void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { if (touches.Count > 0) { // Perform touch handling here } }
void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { if (touches.Count > 0) { } }
void OnTouchEnded(CCTouch touch, CCEvent touchEvent) { bool hits = touchHits(touch); if (hits && Triggered != null) Triggered(this, EventArgs.Empty); scaleButtonTo(1); }
void HandleTouchesMoved(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent) { // we only care about the first touch: var locationOnScreen = touches [0].Location; paddleSprite.PositionX = locationOnScreen.X; }
public void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent) { CCTouch touch = touches.FirstOrDefault(); CCPoint location = touch.Location; List<CCPhysicsShape> shapes = Scene.PhysicsWorld.GetShapes(location); CCPhysicsBody body = null; foreach (var obj in shapes) { if ((obj.Body.Tag & DRAG_BODYS_TAG) != 0) { body = obj.Body; break; } } if (body != null) { CCNode mouse = new CCNode(); mouse.PhysicsBody = new CCPhysicsBody(); mouse.PhysicsBody.IsDynamic = false; mouse.Position = location; AddChild(mouse); CCPhysicsJointPin join = CCPhysicsJointPin.Construct(mouse.PhysicsBody, body, location); join.SetMaxForce(5000 * body.GetMass()); Scene.PhysicsWorld.AddJoint(join); mouses.Add(touch.Id, mouse); } }
void onTouchMoved(CCTouch touch, CCEvent touchEvent) { CCPoint touchLocation = touch.LocationOnScreen; CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation); m_test.MouseMove(new b2Vec2(nodePosition.X, nodePosition.Y)); }
public void OnTouchesEnded(List<CCTouch> touches, CCEvent e) { if (!win) { foreach (CCTouch touch in touches) { for (int i = 0; i < botones.Length; i++) { if (GameData.CheckIfSpriteTouched(touch, botones[i])) { if (llamando == i + 1 && jugadoresActivos[i]) { debug.Text = "Correcto!"; debug.Color = GetColorJugador(i + 1); contesto = true; CCSimpleAudioEngine.SharedEngine.PlayEffect("sounds/coin"); } else { DerrotaJugador(i + 1); } } } } } else { ReturnToMenu(); } }
private void HandleTouchesEnded(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent) { foreach (CCTouch Touch in touches) { if (startGame != null) { startGame (); } } }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { bool hits = touchHits(touch); if (hits) scaleButtonTo(0.9f); return hits; }
bool onTouchBegan(CCTouch touch, CCEvent touchEvent) { if (m_state != PaddleState.kPaddleStateUngrabbed) return false; if (!containsTouchLocation(touch)) return false; m_state = PaddleState.kPaddleStateGrabbed; return true; }
void onTouchesEnded(List<CCTouch> pTouches, CCEvent touchEvent) { drag = false; snapArrowsToEdge(); arrowsBar.Visible = false; UpdateLineHeight(); }
/// <summary> /// If the touch is ended return the visbility of this layer and reverse it. /// </summary> /// <returns><c>true</c> if this layer is visible; otherwise, <c>false</c>.</returns> /// <param name="touches">The touches list.</param> /// <param name="touchEvent">The touch event.</param> public bool OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { if (Visible) { Visible = !Visible; return true; } return false; }
void onTouchesBegan(List<CCTouch> touches, CCEvent touchEvent) { foreach (var it in touches) { CCTouch touch = it; var m_tBeginPos = touch.LocationOnScreen; } }
public void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { foreach (CCTouch touch in touches) { if (touch == Touch) { Touch = null; return; } } }
void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent) { var diff = touches[0].Delta; var node = GetChildByTag((int)KTag.kTagNode); var currentPos = node.Position; node.Position = currentPos + diff; }
void TouchCancelled(CCTouch touch, CCEvent touchEvent) { Debug.Assert(MenuState == CCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); if (SelectedMenuItem != null) { SelectedMenuItem.Selected = false; } MenuState = CCMenuState.Waiting; }
public void OnTouchesMoved(List<CCTouch> touches, CCEvent touchEvent) { foreach (CCTouch touch in touches) { if (touch == Touch) { PositionX = touch.Location.X; PositionY = touch.Location.Y; } } }
//Handle all touches for this scene void handleEndTouches(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent) { var touchLocation = touches[0].Location; //If play is hit if (play.BoundingBoxTransformedToWorld.ContainsPoint(touchLocation)) GameLayer.getNewMap(GameView); //If quit is hit else if (quit.BoundingBoxTransformedToWorld.ContainsPoint(touchLocation)) Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }
bool onTouchBegan(CCTouch touch, CCEvent touchEvent) { CCPoint touchLocation = touch.LocationOnScreen; CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation); // NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); CCLog.Log("OnTouchBegan: " + nodePosition); return m_test.MouseDown(new b2Vec2(nodePosition.X, nodePosition.Y)); }
private void HandleTouchesBegan(List<CCTouch> touches, CCEvent touchEvent) { foreach (var item in touches) { if (item.Location.X > owner.ContentSize.Center.X) { touchedOnRightSide = true; } } }
private void HandleInput(System.Collections.Generic.List<CCTouch> touches, CCEvent touchEvent) { if(touches.Count > 0) { CCTouch firstTouch = touches[0]; this.PositionX = firstTouch.Location.X; this.PositionY = firstTouch.Location.Y; } }
void onTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { foreach (var item in touches ) { CCTouch touch = item; TouchPoint pTP = s_dic[touch.Id]; RemoveChild(pTP, true); s_dic.Remove(touch.Id); } }
void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent) { foreach(var item in touches) { CCTouch touch = item; TouchPoint pTP = s_dic[touch.Id]; CCPoint location = touch.LocationOnScreen; pTP.SetTouchPos(location); } }
void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent) { CCPoint location = LocationFromTouch(pTouch); location = new CCPoint(location.X - initialTouchXPosition, 0); HasMoved = true; switchSprite.SliderXPosition = location.X; }
void onTouchesBegan(List<CCTouch> pTouches, CCEvent touchEvent) { CCTouch touch = pTouches[0]; CCPoint location = touch.Location; if (arrows.BoundingBox.ContainsPoint(location)) { drag = true; arrowsBar.Visible = true; } }
bool onTouchBegan(CCTouch touch, CCEvent touchEvent) { CCPoint touchLocation = touch.Location; CCPoint nodePosition = ConvertToNodeSpace(touchLocation); // NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); m_test.MouseDown(new Vector2(nodePosition.X, nodePosition.Y)); return true; }
void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent) { // Get the touch location CCPoint touchLocation = GetTouchLocation(pTouch); //small modification: this allows changing of the colour, even if the touch leaves the bounding area // UpdateSliderPosition(touchLocation); // sendActionsForControlEvents(ControlEventValueChanged); // Check the touch position on the Slider CheckSliderPosition(touchLocation); }
public void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent) { foreach (CCTouch touch in touches) { if (touch!=null) { // AirHockey uses layer.ScreenToWorldspace(touch.LocationOnScreen) if (BoundingBox.ContainsPoint(touch.Location)) { Touch = touch; return; } } } }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { if (!IsTouchInside(touch) || !Enabled || !Visible) { return(false); } CCPoint location = LocationFromTouch(touch); SliderBegan(location); return(true); }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { if (!IsTouchInside(touch) || !Enabled || !Visible) { return(false); } previousLocation = GetTouchLocation(touch); PotentiometerBegan(previousLocation); return(true); }
//events bool onTouchBegan(CCTouch pTouch, CCEvent touchEvent) { if (!IsTouchInside(pTouch) || !Enabled) { return(false); } State = CCControlState.Highlighted; isPushed = true; Highlighted = true; SendActionsForControlEvents(CCControlEvent.TouchDown); return(true); }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { if (!Enabled || !Visible) { return(false); } // Get the touch location CCPoint touchLocation = GetTouchLocation(touch); // Check the touch position on the Slider return(CheckSliderPosition(touchLocation)); }
void onTouchesMoved(List<CCTouch> touches, CCEvent touchEvent) { CCSize s = Layer.VisibleBoundsWorldspace.Size; var it = touches.FirstOrDefault(); CCTouch touch = (CCTouch)(it); var start = touch.LocationOnScreen; CCPoint diff = new CCPoint(s.Width / 2 - start.X, s.Height / 2 - start.Y); diff = CCPoint.Normalize(diff); gradientLayer.Vector = diff; }
public virtual void TouchCancelled(CCTouch touch, CCEvent touchEvent) { if (!Visible) { return; } touches.Remove(touch); if (touches.Count == 0) { Dragging = false; IsTouchMoved = false; } }
void onTouchesBegan(List<CCTouch> touches, CCEvent touchEvent) { foreach (var item in touches) { CCTouch touch = (item); TouchPoint touchPoint = TouchPoint.TouchPointWithParent(this); CCPoint location = touch.Location; touchPoint.SetTouchPos(location); touchPoint.SetTouchColor(s_TouchColors[touch.Id % 5]); AddChild(touchPoint); s_dic.Add( touch.Id, touchPoint); } }
void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { foreach (CCTouch item in touches) { if (item == null) { break; } var location = Layer.ScreenToWorldspace(item.LocationOnScreen); AddNewSpriteWithCoords(location); } }
void OnTouchCancelled(CCTouch pTouch, CCEvent touchEvent) { CCPoint location = LocationFromTouch(pTouch); switchSprite.ThumbSprite.Color = new CCColor3B(255, 255, 255); if (HasMoved) { On = !(location.X < switchSprite.ContentSize.Width / 2); } else { On = !on; } }
///** Updates all listeners // * 1) Removes all listener items that have been marked as 'removed' when dispatching event. // * 2) Adds all listener items that have been marked as 'added' when dispatching event. // */ void UpdateListeners(CCEvent forEvent) { Debug.Assert(inDispatch > 0, "If program goes here, there should be events to dispatch."); if (forEvent.Type == CCEventType.TOUCH) { UpdateListeners(CCEventListenerTouchOneByOne.LISTENER_ID); UpdateListeners(CCEventListenerTouchAllAtOnce.LISTENER_ID); } else { UpdateListeners(CCEventDispatcher.GetListenerID(forEvent)); } if (inDispatch > 1) { return; } Debug.Assert(inDispatch == 1, "_inDispatch should be 1 here."); List <string> lmKeysToRemove = new List <string>(); foreach (string lv in listenerMap.Keys) { if (listenerMap[lv].IsEmpty) { lmKeysToRemove.Add(lv); } } foreach (string key in lmKeysToRemove) { priorityDirtyFlagMap.Remove(key); listenerMap[key] = null; listenerMap.Remove(key); } if (toBeAddedListeners.Count > 0) { foreach (var listener in toBeAddedListeners) { ForceAddEventListener(listener); } toBeAddedListeners.Clear(); } }
void OnTouchEnded(CCTouch pTouch, CCEvent touchEvent) { MinusSprite.Color = CCColor3B.White; PlusSprite.Color = CCColor3B.White; if (autorepeat) { StopAutorepeat(); } if (IsTouchInside(pTouch)) { CCPoint location = GetTouchLocation(pTouch); Value = this.value + ((location.X < MinusSprite.ContentSize.Width) ? (0.0f - stepValue) : stepValue); } }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { if (!IsTouchInside(touch) || !Enabled) { return(false); } HasMoved = false; CCPoint location = LocationFromTouch(touch); initialTouchXPosition = location.X - switchSprite.SliderXPosition; switchSprite.ThumbSprite.Color = new CCColor3B(166, 166, 166); switchSprite.NeedsLayout(); return(true); }
void onTouchEnded(CCTouch pTouch, CCEvent touchEvent) { if (m_pTrackNode == null) { return; } var endPos = pTouch.LocationOnScreen; if (m_pTrackNode.BoundingBox.ContainsPoint(m_beginPos) && m_pTrackNode.BoundingBox.ContainsPoint(endPos)) { onClickTrackNode(true); } else { onClickTrackNode(false); } }
void onTouchEnded(CCTouch pTouch, CCEvent touchEvent) { State = CCControlState.Normal; isPushed = false; Highlighted = false; if (IsTouchInside(pTouch)) { if (Clicked != null) { OnClicked(); } OnTouchUpInside(); } else { OnTouchUpOutside(); } }
void onTouchEnded(CCTouch pTouch, CCEvent touchEvent) { State = CCControlState.Normal; isPushed = false; Highlighted = false; if (IsTouchInside(pTouch)) { if (OnButtonTap != null) { OnButtonTap(this); } SendActionsForControlEvents(CCControlEvent.TouchUpInside); } else { SendActionsForControlEvents(CCControlEvent.TouchUpOutside); } }
bool OnTouchBegan(CCTouch pTouch, CCEvent touchEvent) { if (!IsTouchInside(pTouch) || !Enabled || !Visible) { return(false); } CCPoint location = GetTouchLocation(pTouch); UpdateLayoutUsingTouchLocation(location); touchInsideFlag = true; if (autorepeat) { StartAutorepeat(); } return(true); }
void TouchMoved(CCTouch touch, CCEvent touchEvent) { Debug.Assert(MenuState == CCMenuState.TrackingTouch, "[Menu TouchMoved] -- invalid state"); CCMenuItem currentItem = ItemForTouch(touch); if (currentItem != SelectedMenuItem) { if (SelectedMenuItem != null) { SelectedMenuItem.Selected = false; } if (currentItem != null) { currentItem.Selected = true; } SelectedMenuItem = currentItem; } }
static string GetListenerID(CCEvent listenerEvent) { string ret = string.Empty; switch (listenerEvent.Type) { case CCEventType.ACCELERATION: ret = CCEventListenerAccelerometer.LISTENER_ID; break; case CCEventType.CUSTOM: var customEvent = (CCEventCustom)(listenerEvent); ret = customEvent.EventName; break; case CCEventType.KEYBOARD: ret = CCEventListenerKeyboard.LISTENER_ID; break; case CCEventType.MOUSE: ret = CCEventListenerMouse.LISTENER_ID; break; case CCEventType.GAMEPAD: ret = CCEventListenerGamePad.LISTENER_ID; break; case CCEventType.TOUCH: // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce. // return UNKNOWN instead. Debug.Assert(false, "Don't call this method if the event is for touch."); break; default: Debug.Assert(false, "Invalid type!"); break; } return(ret); }
/// <summary> /// Dispatches the event /// Also removes all EventListeners marked for deletion from the event dispatcher list. /// </summary> /// <param name="eventToDispatch"></param> public void DispatchEvent(CCEvent eventToDispatch) { if (!IsEnabled) { return; } UpdateDirtyFlagForSceneGraph(); inDispatch++; if (eventToDispatch.Type == CCEventType.TOUCH) { DispatchTouchEvent((CCEventTouch)eventToDispatch); inDispatch--; return; } var listenerID = CCEventDispatcher.GetListenerID(eventToDispatch); SortEventListeners(listenerID); if (listenerMap.ContainsKey(listenerID)) { var listeners = listenerMap [listenerID]; Func <CCEventListener, bool> onEvent = delegate(CCEventListener listener) { eventToDispatch.CurrentTarget = listener.SceneGraphPriority; listener.OnEvent(eventToDispatch); return(eventToDispatch.IsStopped); }; DispatchEventToListeners(listeners, onEvent); } UpdateListeners(eventToDispatch); inDispatch--; }
/** override functions */ public virtual bool TouchBegan(CCTouch pTouch, CCEvent touchEvent) { if (!Visible) { return(false); } var frame = ViewRect; //dispatcher does not know about clipping. reject touches outside visible bounds. if (touches.Count > 2 || IsTouchMoved || !frame.ContainsPoint(container.Layer.ScreenToWorldspace(pTouch.LocationOnScreen))) { return(false); } if (!touches.Contains(pTouch)) { touches.Add(pTouch); } if (touches.Count == 1) { // scrolling touchPoint = Layer.ScreenToWorldspace(pTouch.LocationOnScreen); IsTouchMoved = false; Dragging = true; //Dragging started scrollDistance = CCPoint.Zero; touchLength = 0.0f; } else if (touches.Count == 2) { touchPoint = CCPoint.Midpoint(Layer.ScreenToWorldspace(touches[0].LocationOnScreen), Layer.ScreenToWorldspace(touches[1].LocationOnScreen)); touchLength = CCPoint.Distance(container.Layer.ScreenToWorldspace(touches[0].LocationOnScreen), container.Layer.ScreenToWorldspace(touches[1].LocationOnScreen)); Dragging = false; } return(true); }
public virtual void TouchEnded(CCTouch touch, CCEvent touchEvent) { if (!Visible) { return; } if (touches.Contains(touch)) { if (touches.Count == 1 && IsTouchMoved) { Schedule(DeaccelerateScrolling); } touches.Remove(touch); } if (touches.Count == 0) { Dragging = false; IsTouchMoved = false; } }
bool TouchBegan(CCTouch touch, CCEvent touchEvent) { if (MenuState != CCMenuState.Waiting || !Visible || !Enabled) { return(false); } for (CCNode c = Parent; c != null; c = c.Parent) { if (c.Visible == false) { return(false); } } SelectedMenuItem = ItemForTouch(touch); if (SelectedMenuItem != null) { MenuState = CCMenuState.TrackingTouch; SelectedMenuItem.Selected = true; return(true); } return(false); }
void OnTouchEnded(CCTouch pTouch, CCEvent touchEvent) { SliderEnded(CCPoint.Zero); }
bool onTouchBegan(CCTouch pTouch, CCEvent touchEvent) { m_beginPos = pTouch.LocationOnScreen; return(true); }
void OnTouchMoved(CCTouch touch, CCEvent touchEvent) { CCPoint location = GetTouchLocation(touch); PotentiometerMoved(location); }
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { return(false); }
public virtual void TouchMoved(CCTouch touch, CCEvent touchEvent) { if (!Visible) { return; } if (touches.Contains(touch)) { if (touches.Count == 1 && Dragging) { // scrolling CCPoint moveDistance, newPoint; //, maxInset, minInset; float newX, newY; var frame = ViewRect; newPoint = Layer.ScreenToWorldspace(touches[0].LocationOnScreen); moveDistance = newPoint - touchPoint; float dis = 0.0f; if (Direction == CCScrollViewDirection.Vertical) { dis = moveDistance.Y; } else if (Direction == CCScrollViewDirection.Horizontal) { dis = moveDistance.X; } else { dis = (float)Math.Sqrt(moveDistance.X * moveDistance.X + moveDistance.Y * moveDistance.Y); } if (!IsTouchMoved && Math.Abs(ConvertDistanceFromPointToInch(dis)) < MOVE_INCH) { //CCLOG("Invalid movement, distance = [%f, %f], disInch = %f", moveDistance.x, moveDistance.y); return; } if (!IsTouchMoved) { moveDistance = CCPoint.Zero; } touchPoint = newPoint; IsTouchMoved = true; if (frame.ContainsPoint(touchPoint)) { switch (Direction) { case CCScrollViewDirection.Vertical: moveDistance = new CCPoint(0.0f, moveDistance.Y); break; case CCScrollViewDirection.Horizontal: moveDistance = new CCPoint(moveDistance.X, 0.0f); break; default: break; } newX = container.Position.X + moveDistance.X; newY = container.Position.Y + moveDistance.Y; scrollDistance = moveDistance; SetContentOffset(new CCPoint(newX, newY)); } } else if (touches.Count == 2 && !Dragging) { float len = CCPoint.Distance(Layer.ScreenToWorldspace(touches[0].LocationOnScreen), Layer.ScreenToWorldspace(touches[1].LocationOnScreen)); ZoomScale = ZoomScale * len / touchLength; } } }
void OnTouchEnded(CCTouch touch, CCEvent touchEvent) { PotentiometerEnded(CCPoint.Zero); }
void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent) { CCPoint location = LocationFromTouch(pTouch); SliderMoved(location); }