forked from DaniPTRK/Next-Move
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText.java
More file actions
61 lines (59 loc) · 2.19 KB
/
Text.java
File metadata and controls
61 lines (59 loc) · 2.19 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Cod utilizat pentru obiectele setate cu imagini de tip String.
*/
public class Text extends Actor
{
int difp=0;
/**
* Act - do whatever the Text wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public void showText(int i)
{
//Acest text apare atunci când Aurel atinge unul dintre obiectele cu care poate interacționa.
setImage(new GreenfootImage("Apasa E pentru a utiliza "+getWorld().getObjects(Conducator.class).get(0).getNume(i), 25, Color.WHITE, new Color(0,0,0,0)));
}
//Apariția textului în funcție de culoare, mărime, numărul obiectului, Stringul cu care este setat.
public void TextFadeIn(int j, String a, int size, Color cl)
{
int i;
setImage(new GreenfootImage(a, size, cl, new Color(0,0,0,0)));
getWorld().getObjects(Text.class).get(j).getImage().setTransparency(0);
for(i=0; i<=255; i=i+5)
{
getWorld().getObjects(Text.class).get(j).getImage().setTransparency(i);
Greenfoot.delay(1);
}
}
public void removeText()
{
getWorld().getObjects(Text.class).get(0).getImage().setTransparency(0);
}
public void TextFadeOut(int j)
{
int i;
for(i=255; i>=0; i=i-5)
{
getWorld().getObjects(Text.class).get(j).getImage().setTransparency(i);
Greenfoot.delay(1);
}
}
//Setarea textului în cadranul cu resurse în cazul în care avem peste 10 unități la una dintre resurse.
public void changeExceedingResources(int type, int dif)
{
difp=dif;
switch(type)
{
case 0: setImage(new GreenfootImage("+ "+ difp, 40, Color.YELLOW, new Color(0,0,0,0)));
break;
case 1: setImage(new GreenfootImage("+ "+ difp, 40, Color.GREEN, new Color(0,0,0,0)));
break;
case 2: setImage(new GreenfootImage("+ "+ difp, 40, Color.BLUE, new Color(0,0,0,0)));
break;
}
}
}