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

2017/3/9

how do you make something repeat only once

111213451 111213451

2017/3/9

#
I'm trying to change the size of the actor only once because it keeps getting smaller and I don't know what The constructor is
danpost danpost

2017/3/9

#
111213451 wrote...
I'm trying to change the size of the actor only once because it keeps getting smaller and I don't know what The constructor is
There are many ways to limit it to a one-time action. Obviously, you have found that coding the action in the constructor is one way -- and in this case, probably the best way. The constructor is a block of code that looks like a method, but (1) does not have a return type (in most cases, it would be the 'void' in method declaration lines); and (2) the name of the block has the same name as the class. So, a Player class would have a constructor looking like:
public Player()
// or
public Player(Healthbar bar)
The parameter listing is irrelevant as long as the name is the name of the class and there is no return type given.
You need to login to post a reply.