-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.java
More file actions
35 lines (29 loc) · 994 Bytes
/
button.java
File metadata and controls
35 lines (29 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class button here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class button extends Actor
{
/**
* Act - do whatever the button wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act(String start)
{
if (Greenfoot.mouseMoved(this)) {
} else if (Greenfoot.mouseMoved(null)) {
}
if (Greenfoot.mousePressed(this)) {
getImage().scale((int)Math.round(getImage().getWidth() * 0.9), (int)Math.round(getImage().getHeight() * 0.9));
}
if (Greenfoot.mouseClicked(null) || Greenfoot.mouseDragEnded(null)) {
}
if (Greenfoot.mouseClicked(this)) {
Greenfoot.delay(5);
if (start.equalsIgnoreCase("start")) Greenfoot.setWorld(new MyWorld());
}
}
}