Skip to content

Commit 20feeeb

Browse files
committed
added so isanable have to be true for gamobject to get pressed
1 parent 0cd535b commit 20feeeb

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed
87 Bytes
Binary file not shown.

src/JavaGameEngine/Components/Component.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,27 @@ public void update() {
206206
float y = (parent.getPosition().getY()-((getScale().getY()/2)));
207207

208208
setPosition(new Vector2(x,y).add(getLocalPosition())); // we get the parents position and we add our localPosition
209-
/* update this in the setScale and setRotation instead
210-
setRotation(parent.getRotation().add(getLocalRotation()));
211-
setScale(parent.getScale().add(getLocalScale()));
212-
*/
209+
//update this in the setScale and setRotation instead
210+
setRotation(parent.getRotation().add(getLocalRotation()));
211+
setScale(parent.getScale().add(getLocalScale()));
212+
213213

214214
}
215215
if(components.size()>0){
216216
updateChildren(); // updates all the children
217217
}
218218
//mouse enter and exit
219-
if(insideComp()){
219+
if(insideComp()&&isEnabled){
220220
if(!isMouseInside()){
221221
onMouseEntered();
222222
setMouseInside(true);
223223
}
224224
}
225-
else if (isMouseInside()){
225+
else if (isMouseInside()&&isEnabled){
226226
onMouseExit();
227227
setMouseInside(false);
228228
}
229-
if(isMouseInside()&&Input.isMousePressed()){
229+
if(isMouseInside()&&Input.isMousePressed()&&isEnabled){
230230
onMousePressed();
231231
if(getParent()!=null) getParent().onMousePressed();
232232
}

src/JavaGameEngine/JavaGameEngine.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,9 @@ private static void startGame(){
6262
@Override
6363
public void run() {
6464
calcThread.Update();
65-
}
66-
}, DELAY,DELAY);
67-
Timer timer1 = new Timer();
68-
timer1.schedule(new TimerTask() {
69-
@Override
70-
public void run() {
7165
float current = System.nanoTime();
7266
deltaTime = current - previous;
7367
previous = current;
74-
// Debug.log(totalElapsed);
75-
GAMEWORLD.repaint();
76-
Toolkit.getDefaultToolkit().sync(); // so it does not lag on linux
7768
totalElapsed += deltaTime;
7869

7970
if((totalElapsed/1000000000)>1){
@@ -84,6 +75,17 @@ public void run() {
8475
fps++;
8576
}
8677
}, DELAY,DELAY);
78+
Timer timer1 = new Timer();
79+
timer1.schedule(new TimerTask() {
80+
@Override
81+
public void run() {
82+
83+
// Debug.log(totalElapsed);
84+
GAMEWORLD.repaint();
85+
Toolkit.getDefaultToolkit().sync(); // so it does not lag on linux
86+
87+
}
88+
}, DELAY,DELAY);
8789

8890
}
8991

src/Testing/Coin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Coin() {
2222
sprite.loadAnimation(paths);
2323
sprite.setTimer(20);
2424

25-
setScale(new Vector2(16,16));
25+
setScale(new Vector2(5,5));
2626
addChild(sprite);
2727
SquareCollider b = new SquareCollider();
2828
b.setTrigger(true);

src/Testing/Ground.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public Ground() {
2626
}
2727
*/
2828
SquareCollider s = new SquareCollider();
29+
s.setVisible(true);
2930
s.setLocalPosition(new Vector2(0,0));
3031
//s.setLocalScale(new Vector2(600,0));
3132
addChild(s);

src/Testing/Player.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void onTrigger(Component c) {
4242

4343
if(c.getTag().equals("Coin")){
4444
c.destroy();
45-
instantiate(new Bullet(getPosition().add(new Vector2(20,0)),Vector2.right));
45+
// instantiate(new Bullet(getPosition().add(new Vector2(20,0)),Vector2.right));
4646

4747
}
4848
}

0 commit comments

Comments
 (0)