This site requires JavaScript, please enable it in your browser!
Greenfoot back
Roshan123
Roshan123 wrote ...

4 days ago

Showing text above a moving actor

1
2
Roshan123 Roshan123

4 days ago

#
How to show text above a moving actor Conditions:- 1. Without making another class to show text 2. The text should move above the actor
danpost danpost

4 days ago

#
Roshan123 wrote...
How to show text above a moving actor Conditions:- 1. Without making another class to show text 2. The text should move above the actor
Will the text be constant or should it be changeable? What text is to be displayed? Give example(s).
Roshan123 Roshan123

4 days ago

#
I want it to move for every fps with the tank
Roshan123 Roshan123

4 days ago

#
Example I only want to write name above it
Roshan123 Roshan123

4 days ago

#
I have a tank obj And i want the text to move with the tank and the text is a constant name Show text(Michael Kolling)
danpost danpost

4 days ago

#
Maybe you can use:
getWorld().showText(name, getX(), getY()-45);
at end of constructor and at end of act method, with:
getWorld().showText(null, getX(), getY()-45);
at the beginning of the act method.
Roshan123 Roshan123

4 days ago

#
Will the text move along with the tank???
Roshan123 Roshan123

4 days ago

#
Initially i thought about it but afterwards i thought that it will simply draw it on the background of the world. Ok... Whatever it may be, 1st of all i should try!
danpost danpost

4 days ago

#
Roshan123 wrote...
Will the text move along with the tank???
If you put those line in where I said ... yes.
Roshan123 Roshan123

4 days ago

#
danpost wrote...
Roshan123 wrote...
Will the text move along with the tank???
If you put those line in where I said ... yes.
Ok!!)
Roshan123 Roshan123

4 days ago

#
danpost wrote...
Maybe you can use:
getWorld().showText(name, getX(), getY()-45);
at end of constructor and at end of act method, with:
getWorld().showText(null, getX(), getY()-45);
at the beginning of the act method.
Error- An attempt was used to use actor location. Either it has been removed or i don't remember
danpost danpost

4 days ago

#
Roshan123 wrote...
Error- An attempt was used to use actor location. Either it has been removed or i don't remember
Sorry. Remove line from end of constructor. Add the following method:
protected void addedToWorld(World world)
{
    world.showText(name, getX(), getY()-45);
}
Roshan123 Roshan123

3 days ago

#
//constructor 
protected void addedToWorld(World world)
{
    world.showText(name, getX(), getY()-45);
}
public void act
{
getWorld().showText(null, getX(), getY()-45);
//Rest of the code
}
Its still not adding text
danpost danpost

3 days ago

#
Roshan123 wrote...
<< Code Omitted >> Not adding to the world
You should have line 4 AGAIN before line 10.
Roshan123 Roshan123

3 days ago

#
//Constructor
protected void addedToWorld(World world)
{
    world.showText(name, getX(), getY()-45);
}
public void act
{
getWorld().showText(null, getX(), getY()-45);
//Rest of the code
getWorld().showText(name, getX(), getY()-45);
}
Do u mean something like this???
There are more replies on the next page.
1
2