Last change
on this file since a79ce1b was 205f525, checked in by dportnoy <devnull@…>, 14 years ago |
Added some buttons to the main menu. Added a new package to the project to make gui creation easier.
|
-
Property mode
set to
100644
|
File size:
758 bytes
|
Rev | Line | |
---|
[205f525] | 1 | package com.example.gui;
|
---|
| 2 |
|
---|
| 3 | import android.graphics.*;
|
---|
| 4 |
|
---|
| 5 | public class GUIObject {
|
---|
| 6 | protected int x, y, width, height;
|
---|
| 7 | protected Paint p; //all properties of the object are determined through the paint object
|
---|
| 8 |
|
---|
| 9 | public GUIObject(int newX, int newY, int newWidth, int newHeight, Paint p) {
|
---|
| 10 | x = newX;
|
---|
| 11 | y = newY;
|
---|
| 12 | width = newWidth;
|
---|
| 13 | height = newHeight;
|
---|
| 14 | this.p = p;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | public void draw(Canvas c) {
|
---|
| 18 |
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public boolean isClicked(float xCoord, float yCoord) {
|
---|
| 22 | return x <= xCoord && xCoord <= x+width && y <= yCoord && yCoord <= y+height;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public int getX() {
|
---|
| 26 | return x;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public int getY() {
|
---|
| 30 | return y;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public int getWidth() {
|
---|
| 34 | return width;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public int getHeight() {
|
---|
| 38 | return height;
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.