[ad_1]
Game Development Stack Exchange is a query and reply website for skilled and unbiased recreation builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The finest solutions are voted up and rise to the highest
Asked
Viewed
413 occasions
-
When I hit an object, my Fighter is meant to fall to the Ground however due to the Accelerometer, I can nonetheless transfer it up and down regardless that it died. The Scroller on the x-Axis although stops.
Question: (FIXED) How can I make the Accelerometer cease, after I’ve been hit, and make the Fighter speed up to the bottom (in absence of the accelerometer, all by itself)? -
When I transfer the Fighter up and down, the transition from “transferring up” to “transferring down” is not easy. It looks as if it lags.
Question: How can I Increase the Sensitivity of my Accelerometer? -
Also, after I tilt the telephone additional, the speed stays the identical.
Question: How can I enhance the speed, in relation to the lean diploma?
The code is under:
Accelerometer Code:
float accelY = Gdx.enter.getAccelerometerY();
if (Gdx.enter.getAccelerometerY() < 5){
velocity.y = -40;
}
if (Gdx.enter.getAccelerometerY() > 5){
velocity.y = 40;
}
When Fighter hits an Object and dies:
public void die() {
isAlive = false;
velocity.y = 0;
acceleration.y = 460;
}
$endgroup$
Check if the participant is alive earlier than making use of the enter.
float accelY = Gdx.enter.getAccelerometerY();
if(isAlive) {
if (Gdx.enter.getAccelerometerY() < 5){
velocity.y = -40;
}
if (Gdx.enter.getAccelerometerY() > 5){
velocity.y = 40;
}
}
$endgroup$
Why do you replace the speed of your fighter instantly from the accelerometer?
You ought to as a substitute replace its acceleration.
By doing this, the actions will probably be easy.
This can be the explanation why the speed stays the identical in the event you tilt the telephone additional: you might be all the time setting the speed to + or – 40.
$endgroup$
For 2 and three I’d attempt to multiply like so:
Scaling = 1.2f;
If(Gdx.enter.getAcceleratorY() < 5){
Velocity.y = (Gdx.enter.getAcceleratorY()*scaling)*(-1);
}else if(Gdx.enter.getAcceleratorY() >= 5)
Velocity.y = Gdx.enter.getAcceleratorY()*scaling;
}
Try completely different values for scaling (in all probability must be larger than 1). This ought to lead to a extra smart, smoother and sooner transferring of your fighter.
$endgroup$
You should log in to reply this query.
lang-java
[ad_2]