mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2024-11-10 06:52:06 +00:00
java: added crouch button to UI
This commit is contained in:
parent
fe27dfaf97
commit
07435ab070
2 changed files with 20 additions and 0 deletions
BIN
app/src/main/assets/btn_crouch.png
Executable file
BIN
app/src/main/assets/btn_crouch.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -259,6 +259,26 @@ public class ETLActivity extends SDLActivity implements JoyStickListener
|
|||
|
||||
mLayout.addView(btn_alternative, lp_alternative);
|
||||
|
||||
ImageButton btn_crouch = new ImageButton(getApplicationContext());
|
||||
btn_crouch.setImageBitmap(getBitmapFromAsset("btn_crouch.png"));
|
||||
btn_crouch.setBackgroundResource(0);
|
||||
btn_crouch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SDLActivity.onNativeKeyDown(31);
|
||||
SDLActivity.onNativeKeyUp(31);
|
||||
}
|
||||
});
|
||||
|
||||
RelativeLayout.LayoutParams lp_crouch = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
lp_crouch.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
lp_crouch.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
lp_crouch.bottomMargin = pxToDp(-20);
|
||||
|
||||
mLayout.addView(btn_crouch, lp_crouch);
|
||||
|
||||
JoyStick joyStick_left = new JoyStick(getApplicationContext());
|
||||
|
||||
|
|
Loading…
Reference in a new issue