// ---- Left Touch ---- public IEnumerator CoLeftTouch(TouchInput touchInput) { swipeEnded = false; int i = 0; int deltaMove = Mathf.Abs((int)(touchInput.touchBeganPosition.x - touchInput.touchPosition.x)); while (!swipeEnded) { yield return(new WaitForFixedUpdate()); deltaMove = Mathf.Abs((int)(touchInput.touchBeganPosition.x - touchInput.touchPosition.x)); while (i < deltaMove) { yield return(new WaitForFixedUpdate()); MoveBlock(stepLeft); i++; } } /* * while(!swipeEnded) * { * yield return new WaitForFixedUpdate(); * if(transform.position.x > touchInput.touchPosition.x) * MoveBlock(stepLeft); * }*/ }
public GameState(T game) { Game = game; CurrentState = this; Touch = new TouchInput(); Mouse = new MouseInput(); }
} // end of Update() private bool UpdateNonMenuItems() { bool inputHandled = false; // Check for click on signOut tile or url. if (MouseInput.Left.WasPressed || Actions.Select.WasPressed || TouchInput.WasTouched || TouchInput.WasLastReleased) { TouchContact touch = TouchInput.GetOldestTouch(); Vector2 touchHit = new Vector2(-1, -1); // touch off screen if no touch was found // url is in rt coords. if (touch != null) { touchHit = ScreenWarp.ScreenToRT(touch.position); } Vector2 mouseHit = MouseInput.GetMouseInRtCoords(); if (shared.urlBox.Contains(mouseHit) || (shared.urlBox.Contains(touchHit) && TouchInput.WasLastReleased)) { #if NETFX_CORE Launcher.LaunchUriAsync(new Uri(KoduGameLabUrl)); #else Process.Start(KoduGameLabUrl); #endif MouseInput.Left.ClearAllWasPressedState(); inputHandled = true; } } return(inputHandled); }
void Awake() { close = UIUtil.FindChild <SpriteRenderer>(transform, "Close"); open = UIUtil.FindChild <SpriteRenderer>(transform, "Open"); lock_icon = UIUtil.FindChild <SpriteRenderer>(transform, "LockIcon"); touch_input = GetComponent <TouchInput>(); if (null == touch_input) { throw new MissingComponentException("TouchInput"); } touch_input.on_touch_up += (Vector3 position) => { StartCoroutine(Open()); }; Util.EventSystem.Subscribe(EventID.Shop_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.Shop_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.Inventory_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.Inventory_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.TextBox_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.TextBox_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.NPC_Dialogue_Start, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.NPC_Dialogue_Finish, () => { touch_input.block_count--; }); }
void MoveTouchPos(int num) { if (touchNum == num) { if (touchPosOrigin.x < 0) //left of screen { float length = TouchInput.GetTouchWorldPosition(cam, num).x - touchPos.x; if (length > 0.2f) { length = 0.2f; touchPos.x = TouchInput.GetTouchWorldPosition(cam, num).x - 0.2f; } if (length < -0.2f) { length = -0.2f; touchPos.x = TouchInput.GetTouchWorldPosition(cam, num).x + 0.2f; } if (length > 0.05f) { direction = 1; Move(direction, length); } else if (length < -0.05f) { direction = -1; Move(direction, length); } else { Move(0, 0); } } } }
void Init() { myTransform = transform; canMove = true; canJumpAgain = true; canSlideAgain = true; canRollLeftAgain = true; canRollRightAgain = true; #if UNITY_EDITOR keyboardInput = ExtendedGameObject.SetComponent <Keyboard_Input>(gameObject); #elif UNITY_ANDROID touchInput = ExtendedGameObject.SetComponent <TouchInput>(gameObject); #endif anim = ExtendedGameObject.SetComponent <Animator>(gameObject); MainCameraGO = GameObject.Find("Main Camera"); if (MainCameraGO == null) { Debug.Log("Cant find main camera"); return; } cameraFollower = ExtendedGameObject.SetComponent <CameraFollower>(MainCameraGO); cameraFollower.followTarget = gameObject.transform; capCollider = ExtendedGameObject.SetComponent <CapsuleCollider>(gameObject); base.Init(); MakeUninvisible(); didInit = true; }
public void Init(int id) { spriteRenderer = GetComponent <SpriteRenderer> (); blockTile = null; block = null; this.id = id; if (0 != id) { spriteRenderer.color = color; } else { //spriteRenderer.color = deactiveColor; gameObject.SetActive(false); } #if UNITY_EDITOR if (true == Map.Instance.editMode) { gameObject.SetActive(true); spriteRenderer.color = Color.white; if (0 != id) { spriteRenderer.color = Color.gray; } TouchInput touch = gameObject.AddComponent <TouchInput>(); touch.onTouchUp += (Vector3 position) => { Editor.Instance.OnClickMapTile(this); }; } #endif }
private void Awake() { dungeon = GetComponent <Dungeon>(); if (null == dungeon) { throw new MissingComponentException(typeof(Dungeon).Name); } touch_input = GetComponent <TouchInput>(); if (null == touch_input) { throw new MissingComponentException(typeof(TouchInput).Name); } Util.EventSystem.Subscribe(EventID.Dungeon_Battle_Start, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe <DungeonBattle.BattleResult>(EventID.Dungeon_Battle_Finish, (DungeonBattle.BattleResult result) => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.Shop_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.Shop_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.Inventory_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.Inventory_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.TextBox_Open, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.TextBox_Close, () => { touch_input.block_count--; }); Util.EventSystem.Subscribe(EventID.NPC_Dialogue_Start, () => { touch_input.block_count++; }); Util.EventSystem.Subscribe(EventID.NPC_Dialogue_Finish, () => { touch_input.block_count--; }); }
void HandleOnTouchBegan(int touchIndex, TouchInputParameters inputParameters, TouchInput sender) { if (isEventMaster) { (activePointers[0] as TouchInputPointer).PointerInputDown(touchIndex, inputParameters, sender, 0, false); } }
void HandleOnClick(int touchIndex, TouchInputParameters inputParameters, TouchInput sender) { if (isEventMaster) { (activePointers[0] as TouchInputPointer).PointerInputTimeClick(touchIndex, inputParameters, sender, 0, false); } }
} // end of c'tor public void Update() { if (active) { scrollableTextDisplay.Update(null); if (scrollableTextDisplay.Active) { return; } // // Input? // if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { for (int i = 0; i < TouchInput.TouchCount; i++) { TouchContact touch = TouchInput.GetTouchContactByIndex(i); Vector2 touchHit = touch.position; HandleTouchInput(touch, touchHit); } } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { Vector2 hit = MouseInput.PositionVec; HandleMouseInput(hit); } } } // end of Update()
void OnTouchMove(int num) { if (num == 0) { if (touchPosCurrent != null) { touchPosBefore = touchPosCurrent; } if (touchPosAnchor == null) { touchPosAnchor = TouchInput.GetTouchPosition(num); } else { touchPosBefore = TouchInput.GetTouchPosition(num); } touchPosCurrent = TouchInput.GetTouchPosition(num); //タッチアンカー値制限 if (touchPosAnchor != null && touchPosCurrent != null) { Vector2 dist = (Vector2)touchPosCurrent - (Vector2)touchPosAnchor; if (dist.magnitude >= 40) { touchPosAnchor = touchPosCurrent - dist.normalized * 40; } } TouchGesture gesture = PositionToGesture((Vector2)touchPosAnchor, (Vector2)touchPosCurrent); EventManager.Invoke(ref EventManager.OnTouchGestureMove, num, gesture); } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. SpriteBatch = new SpriteBatch(GraphicsDevice); GameData = new GamePersistance <GameData>(this); Pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); Pixel.SetData(new[] { Color.White }); Textures.LoadContent(Content); Font = new FontTexture(Content.Load <Texture2D>(@"Images\EditSysLarge.png"), 58, 8, -10, new[] { 26, 22, 36, 36, 50, 47, 40, 21, 28, 28, 29, 33, 26, 40, 22, 47, 47, 33, 47, 47, 47, 47, 47, 47, 47, 47, 26, 26, 51, 40, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 26, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 29, 47, 29, 33, 47, 26, 31, 33, 30, 33, 32, 28, 33, 31, 22, 26, 32, 21, 40, 31, 24, 33, 33, 27, 29, 28, 31, 33, 40, 32, 33, 31, 33, 21, 33, 33, 31 }); Mouse = new MouseInput(); IsMouseVisible = false; Touch = new TouchInput(); UnifiedInput = new UnifiedInput(this); KeyboardInput = new KeyboardInput(this); UnifiedInput.TapListeners.Add(Tap); Branding.BackgroundColor = Color.Black; Audio.Play(Cues.Music01, AudioChannels.Music, true); _currentComponent = new Intro(this, null); }
public void Init(Block block) { this.block = block; transform.SetParent(block.transform, false); tileSprite = transform.Find("TileSprite").GetComponent <SpriteRenderer> (); outlineSprite = transform.Find("OutlineSprite").GetComponent <SpriteRenderer>(); outlineSprite.gameObject.SetActive(false); touchInput = GetComponent <TouchInput> (); touchInput.onTouchDown = null; touchInput.onTouchDown += (Vector3 position) => { block.OnClick(position); }; touchInput.onTouchDrag = null; touchInput.onTouchDrag += (Vector3 delta) => { block.OnDrag(delta); }; touchInput.onTouchUp = null; touchInput.onTouchUp += (Vector3 position) => { Vector3 delta = Vector3.zero; if (null != mapTile) { delta = mapTile.transform.position - transform.position; } block.OnDrop(block.transform.position + delta); }; boxCollier = GetComponent <BoxCollider> (); }
void FillButton() { if (buttonPressed == true) { if (EventSystem.current.currentSelectedGameObject != null) { fill = EventSystem.current.currentSelectedGameObject.transform.parent.gameObject; Image fillImg = fill.GetComponent <Image>(); RectTransform rect = fill.GetComponent <RectTransform>(); fill.GetComponent <Image>().color = Color.Lerp(fill.GetComponent <Image>().color, color, 0.2f); if (Input.touchPressureSupported) { fillImg.fillAmount = Mathf.Lerp(fillImg.fillAmount, TouchInput.NormilizedPressure(), 0.75f); } else { fillImg.fillAmount = Mathf.Lerp(fillImg.fillAmount, TouchInput.Held(0, 1, fillImg.fillAmount, 0.06f), 0.75f); } rect.localScale = Vector2.Lerp(rect.localScale, startSize * 1.12f, 0.2f); if (fillImg.fillAmount > .995f) { SceneManager.LoadScene("SurvivalV1"); } } } }
// Use this for initialization void Start() { input = FindObjectOfType <TouchInput>(); sh = input.sh; tm = input.tm; der = GetComponent <SphereCollider>(); }
/// <summary> /// /// </summary> /// <returns>Returns true if autorepeating.</returns> public bool Update() { bool result = false; hitBox.Set(position, position + size); // If pressed, see if touch is still active. If not, clear pressed state. if (Pressed) { TouchContact touch = TouchInput.GetOldestTouch(); if (touch == null || touch.phase == TouchPhase.Ended) { Pressed = false; } // If previously pressed, check for possible autorepeat. // Don't do this for keys with delegates (transition keys). // They should never autorepeat. if (Pressed && OnKey == null) { // Waited long enough to autorepeat? if (Time.GameTimeTotalSeconds - timeOfLastPress >= GamePadInput.Button.AutoRepeatDelay) { if (Time.GameTimeTotalSeconds - timeOfLastRepeat >= 1.0 / GamePadInput.Button.AutoRepeatRate) { // Trigger an autorepeat. result = true; timeOfLastRepeat = Time.GameTimeTotalSeconds; } } } } return(result); } // end of Update()
// -------- Down -------- // ---- Quick Down Touch ---- public IEnumerator coQuickDownTouch(TouchInput touchInput) { yield return(new WaitForFixedUpdate()); //userInput.LockInput(true); //BlockFallStop(); //StartCoroutine(QuickFall()); }
public CapTouchDriver(I2CDevice sharedBus) { display = new DisplayNhd5(sharedBus); //LCDbacklight = new OutputPort(GHI.Pins.G120.P1_19, true); //LCDbacklight.Write(true); msBacklightTime = 0; // Default is off msDisplayTimeout = 0; display.TouchUp += display_TouchUp; display.TouchDown += display_TouchDown; display.ZoomIn += display_ZoomIn; display.ZoomOut += display_ZoomOut; touches = new Microsoft.SPOT.Touch.TouchInput[1]; touches[0] = new TouchInput(); // // Using interrupt (for G120) // //touchPin = new InterruptPort(GHI.Pins.G120.P0_25, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); touchPin = new InterruptPort(GHI.Pins.G120.P2_21, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); touchPin.OnInterrupt += touchPin_OnInterrupt; // // Create thread the handle the backlight timeout // Thread threadBacklight = new Thread(backlightHandler); threadBacklight.Start(); }
void OnTouchStart(Touch touch) { if (isPressed && inputs.Count == panFingerCount) { TouchInput panTouch = inputs.Values.First(i => i.id != fingerId); } }
void Start() { _groundTransform = Ground.GetComponent <Transform>(); _elephantMovement = GetComponent <TouchInput>(); Hole.GetComponent <SpriteRenderer>().enabled = false; AudioMngr = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); }
void Update() { int touchNum = 1; #if (UNITY_EDITOR || UNITY_STANDALONE) #else touchNum = Input.touchCount; #endif for (int i = 0; i < touchNum; i++) { if (TouchInput.GetTouch(i) == TouchInfo.Began) { EventManager.Invoke(ref EventManager.OnTouchBegin, TouchInput.GetID(i)); } if (TouchInput.GetTouch(i) == TouchInfo.Moved || TouchInput.GetTouch(i) == TouchInfo.Stationary) { EventManager.Invoke(ref EventManager.OnTouchMove, TouchInput.GetID(i)); } if (TouchInput.GetTouch(i) == TouchInfo.Ended) { EventManager.Invoke(ref EventManager.OnTouchEnd, TouchInput.GetID(i)); } } /* * for(int i = 0;i < touchNum; i++){ * if (touchState.ContainsKey (i)) { * touchState [i] = TouchInput.GetTouch (i); * // Debug.Log (i); * } else { * * touchState.Add (i, TouchInfo.Began); * } * }*/ }
// Update is called once per frame void Update() { if (shootingEnabled) { //Check for shot touch if (TouchInput.TouchIsValid(TouchDefines.shotTouchID)) { //If there has been enough time since the last shot then create a new bullet if (shotTimer < 0) { //Spawn bullets at all of the bullet spawn points for (int i = 0; i < bulletSpawns.Length; i++) { //Create Bullet, set it's postion and direction ShipBullet createdBullet = Instantiate(bulletPrefab).GetComponent <ShipBullet>(); createdBullet.transform.position = transform.TransformPoint(bulletSpawns[i]); createdBullet.transform.rotation = gameObject.transform.rotation; createdBullet.BulletCreator = gameObject; } //Play Shooting Sound if (shootingAudioSource && shootingSound) { shootingAudioSource.PlaySFX(shootingSound); } //Reset Shot Timer shotTimer = shotSpacing; } } //Decrease shot time shotTimer -= Time.deltaTime; } }
void Update() { // Update the existing contacts. for (var i = 0; i < _contacts.Length; i++) { // If the contact is alive, try retrieving the latest state. if (_contacts[i].IsValid) { _contacts[i] = TouchInput.GetContact(_contacts[i].ID); } // Update the target spray. UpdateTarget(_targets[i], _contacts[i]); } // Add new entries to the contact array. var newEntries = TouchInput.NewContacts; for (var i1 = 0; i1 < newEntries.Length; i1++) { // Find an unsed contact. for (var i2 = 0; i2 < _contacts.Length; i2++) { if (!_contacts[i2].IsValid) { // Start using this one. _contacts[i2] = newEntries[i1]; UpdateTarget(_targets[i2], _contacts[i2]); break; } } } }
Vector3 GetKeyboardTranslationDirection() { Vector3 direction = new Vector3(); if (!TouchInput.IsKeyboardConsumedByUI()) { if (Input.GetKey(KeyCode.W)) { direction += Vector3.forward; } if (Input.GetKey(KeyCode.S)) { direction += Vector3.back; } if (Input.GetKey(KeyCode.A)) { direction += Vector3.left; } if (Input.GetKey(KeyCode.D)) { direction += Vector3.right; } } return(direction); }
// ---- Down Touch ---- public IEnumerator CoDownTouch(TouchInput touchInput) { /* * swipeEnded = false; * while(!swipeEnded) * { * yield return new WaitForFixedUpdate(); * //if(transform.position.y > touchInput.touchPosition.y) * MoveBlock(stepDown); * }*/ swipeEnded = false; int i = 0; int deltaMove = Mathf.Abs((int)(touchInput.touchBeganPosition.y - touchInput.touchPosition.y)); while (!swipeEnded) { yield return(new WaitForFixedUpdate()); deltaMove = Mathf.Abs((int)(touchInput.touchBeganPosition.y - touchInput.touchPosition.y)); while (i < deltaMove) { yield return(new WaitForFixedUpdate()); MoveBlock(stepDown); i++; } } }
private void FixedUpdate() { //Get the amount of input rotation float inputRotation = 0f; if (TouchInput.TouchIsValid(TouchDefines.movementTouchID)) { //Get the input touch, now we know its valid, then get get the amount //that touch has moved in the direction that we use to rotate the car //then mutiply it by the rotation amount so it does something significant to //the car Touch inputTouch = Input.GetTouch(TouchDefines.movementTouchID); inputRotation = TouchInput.GetTouchMovementInDirection(inputTouch, expectedSwipeAxis) * rotationAmount; } if (objectRB != null) { //Move the player forward objectRB.MovePosition(objectRB.position + transform.forward * (moveSpeed * Time.fixedDeltaTime)); //Get the current rotation Quaternion currentRotation = objectRB.rotation; //Get the amount of rotation the user has inputted and apply it in the y direction Vector3 yRotation = Vector3.up * (inputRotation * rotationSpeed * Time.fixedDeltaTime); //Convert this rotation to a Quaternion Quaternion deltaRotation = Quaternion.Euler(yRotation); //Work out our target rotation Quaternion targetRotation = currentRotation * deltaRotation; objectRB.MoveRotation(Quaternion.Slerp(currentRotation, targetRotation, rotationSpeed * Time.deltaTime)); } }
// Update is called once per frame void FixedUpdate() { // Set the direction of aim based on position of mouse, touch &&|| click Vector3 direction; direction = new Vector3( TouchInput.getTouch().x - turningAxis.transform.position.x, TouchInput.getTouch().y - turningAxis.transform.position.y, 0); //Turn the guns axis in the right direction turningAxis.transform.right = direction; //Resatrain gun angle turningAxis.transform.rotation = Quaternion.Euler(0, 0, Mathf.Clamp(turningAxis.transform.eulerAngles.z, 80, 180)); //On click || pres, & if alowed by firecountown call Shoot(), to execute fireing if (TouchInput.Shoot() && firecountdown >= 1f) { //Change the value to 1 to represent "per second" firecountdown = 0f; Shoot(); } // fire rate of 0,5 would represent 0,5 shots per second, fire countdown previously set to 1 firecountdown += Time.deltaTime * fireRate; }
/// <summary> /// Handler for the touch up event /// </summary> /// <param name="sender">The sender for this touch event</param> /// <param name="e">The event arguments</param> private void TouchUpHandler(object sender, TouchScreenEventArgs e) { TouchInput ti = e.Touches[0]; string fire = "Fire was pressed"; string snowflake = "Snowflake was pressed"; string text; switch (_currentScreenId) { case ScreenId.NorthEast: text = _ar[0].Contains(ti) ? fire : snowflake; break; case ScreenId.NorthWest: text = _ar[1].Contains(ti) ? fire : snowflake; break; case ScreenId.SouthWest: text = _ar[2].Contains(ti) ? fire : snowflake; break; case ScreenId.SouthEast: text = _ar[3].Contains(ti) ? fire : snowflake; break; default: throw new InvalidOperationException("This is not expected!"); } Debug.Print(text); }
void Update() { // Update the existing contacts. for (var i = 0; i < kMaxContacts; i++) { // If the contact is alive, try retrieving the latest state. if (_contacts[i].IsValid) { _contacts[i] = TouchInput.GetContact(_contacts[i].ID); } UpdateIndicator(_indicators[i], _contacts[i]); SwitchParticle(_indicators[i], _contacts[i].IsValid); } // Add new entries to the contact array. var newEntries = TouchInput.NewContacts; for (var i1 = 0; i1 < newEntries.Length; i1++) { // Find an unsed contact. for (var i2 = 0; i2 < _contacts.Length; i2++) { if (!_contacts[i2].IsValid) { // Start using this one. Don't enable the particle system // at this point to avoid particle emission by jump. _contacts[i2] = newEntries[i1]; UpdateIndicator(_indicators[i2], _contacts[i2]); break; } } } }
// Update is called once per frame void Update () { if(TouchInput == null) { TouchInput = GameObject.FindObjectOfType<TouchInput>(); } TouchInput.UpdateInput(true); }
public RawTouchInputReport(PresentationSource inputSource, DateTime timestamp, byte eventMessage, TouchInput[] touches, UIElement destTarget) : base(inputSource, timestamp) { EventMessage = eventMessage; Touches = touches; Target = destTarget; }
void Update() { if (TouchInput == null) { TouchInput = AquireInput(); } else { TouchInput.UpdateInput(isLocalPlayer); } }
void Awake () { startPos = transform.position; AIControl = GetComponent<AIController>(); if (PlayerNum == 1 && PlayerPrefs.GetString("gamemode") == "singleplayer") { PlayerIsAI = true; } touchInput = GameObject.Find ("GameHandler").GetComponent<TouchInput>(); }
public bool Contains(TouchInput input) { if( input.X >= this.X && input.X < this.X + this.Width && input.Y >= this.Y && input.Y < this.Y + this.Height ) { return true; } return false; }
public void touchStateChanged (TouchInput []touches) { if(!IsActivated) return; TouchInput touch = touches [0]; if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject (-1) || UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject (touch.fingerId)) return; switch (touch.phase) { case TouchPhase.Began: break; case TouchPhase.Moved: break; case TouchPhase.Ended: Vector3 worldTouchPos = Camera.main.ScreenToWorldPoint(touch.end); worldTouchPos = new Vector3(worldTouchPos.x,worldTouchPos .y,0); if(this.GetComponent<BoxCollider2D>().bounds.Contains(worldTouchPos)) { Wait(); Jump(); if(this.GetComponent<RandomSound>()) this.GetComponent<RandomSound>().Play(); } break; } }
void Start() { SetUsedButtons(); m_clrArrowOrig = m_arrBtns[0].color; m_nDownFlags = m_nEnterFlags = m_nReleasedFlags = 0; m_TI = GameObject.Find("MobileInputControls").GetComponent<TouchInput>(); }
public static extern void SetTouchInput(TouchInput flag, int param1, int param2, int param3);
public static extern void GetTouchInput(TouchInput flag, ref int param1, ref int param2, ref int param3);
private void Start() { if (_instance == null) _instance = this; else if (_instance != this) Debug.LogError("Second instance of TouchInput."); }
// Methods public TouchScreenEventArgs(DateTime timestamp, TouchInput[] touches, object target) { this.Touches = touches; this.TimeStamp = timestamp; this.Target = target; }
public void touchStateChanged (TouchInput []touches) { if(state != GameStateType.Start && state != GameStateType.Pregame) return; TouchInput touch = touches [0]; float range = 50; switch (touch.phase) { case TouchPhase.Began: _deltaMovement = Vector2.zero; break; case TouchPhase.Moved: // _deltaMovement += touch.deltaPosition; break; case TouchPhase.Ended: _deltaMovement = touch.end - touch.start; if (Mathf.Abs (_deltaMovement.x) > Mathf.Abs (_deltaMovement.y) && _deltaMovement.x > range ) { ExecuteSwipe(DirectionType.Right); } else if (Mathf.Abs (_deltaMovement.x) > Mathf.Abs (_deltaMovement.y) && _deltaMovement.x < -range ) { ExecuteSwipe(DirectionType.Left); } else if (Mathf.Abs (_deltaMovement.y) > Mathf.Abs (_deltaMovement.x) && _deltaMovement.y < -range ) { ExecuteSwipe(DirectionType.Down); } break; } }
// Methods public TouchEventArgs(InputDevice inputDevice, DateTime timestamp, TouchInput[] touches) : base(inputDevice, timestamp) { Touches = touches; }
public TouchEventArgs(TouchInput[] touches, DateTime timestamp) { //Touches = touches; Timestamp = timestamp; Point = new Point(touches[0].X, touches[0].Y); }
/// <summary> /// Constructs an instance of the RawKeyboardInputReport class. /// </summary> /// <param name="inputSource"> /// source of the input /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> public RawTouchInputReport(PresentationSource inputSource, DateTime timestamp, byte eventMessage, TouchInput[] touches) : base(inputSource, timestamp) { EventMessage = eventMessage; Touches = touches; }