movement = Input.GetAxis ("Horizontal");
if (movement > 0f) {
rigidBody.velocity = new Vector2 (movement * speed, rigidBody.velocity.y);
transform.localScale = new Vector2(0.1483552f,0.1483552f);
}
else if (movement < 0f) {
rigidBody.velocity = new Vector2 (movement * speed, rigidBody.velocity.y);
transform.localScale = new Vector2(-0.1483552f,0.1483552f);
}
else {
rigidBody.velocity = new Vector2 (0,rigidBody.velocity.y);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
play_sound();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
play_sound();
}
}
private void play_sound()
{
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
}