void FixedUpdate() { //check if we're grounded, if no we are falling fire = CrossPlatformInputManager.GetButton("Fire"); jump = CrossPlatformInputManager.GetButton("Jump"); grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer); myAnim.SetBool("isGrounded", grounded); myAnim.SetFloat("verticalSpeed", myRB.velocity.y); //move = CrossPlatformInputManager.GetAxis("Horizontal"); move = 7 * Mathf.Sin(AccelerometerInput.GetAxis()); if (Mathf.Abs(move) < 0.8) { move = 0; } myAnim.SetFloat("speed", Mathf.Abs(move)); movement.Set(move * maxSpeed, 0); if (grounded && move != 0) { myRB.AddForce(movement); } if (move > 0 && facingRight == false) { flip(); } else if (move < 0 && facingRight == true) { flip(); } }
private void Update() { if (AccelerometerInput.isAccelerometerActive() && dataButton.interactable) { dataButton.interactable = false; } else if (!AccelerometerInput.isAccelerometerActive() && !dataButton.interactable) { dataButton.interactable = true; } }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
void OnTriggerEnter(Collider other) { if ((other.gameObject.name == "player" || other.gameObject.name == "SuperMan") && xa.goal1 == 1) { xa.gameFinish = true; switch (xa.levelNumber) { case 1: Player.end(); AccelerometerInput.end(); break; case 2: Player.end(); Freeze.end(); break; case 3: Player.end(); Super.end(); break; } Destroy(gameObject); if (xa.levelStatus != "y") { xa.levelStatus = "y"; } int lc = Player.lifeCount; if (lc == 2) { if (xa.coinCount == Player.coinCount) { stars = 3; } else { stars = 2; } } else if (lc == 1 || lc == 0) { if (xa.coinCount == Player.coinCount) { stars = 2; } else { stars = 1; } } if (xa.levelStars < stars) { xa.levelStars = stars; } level.updateConfig(xa.levelNumber, xa.levelStatus, xa.levelStars); if (gamefinish == null) { gamefinish = getCanvas(); } image = gamefinish.gameObject.GetComponentInChildren <Image>(); image.sprite = starImages [stars - 1]; gamefinish.enabled = true; Time.timeScale = 0; xa.levelNumber = 0; } }
// Use this for initialization void Start() { acc = AccelerometerInput.instance; }