-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create-a-simple-hud #17
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestions!
Except for the individual comments in your markdown file, please make the following changes:
- Provide metainformation. Not all of our docs pages have these already, I know.
For example, see this site. - name your image files in lowercased letters.
- name your markdown files in lowercased letters without spacing and special characters. Use create-a-simple-hud.md instead.
import de.gurkenlabs.litiengine.util.Imaging; | ||
|
||
import javax.tools.Tool; | ||
import java.awt.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No wildcard imports, please.
|
||
public class HUD extends GuiComponent { | ||
//create variables for our images that we want to render later, and scale them to the desired size | ||
private static final BufferedImage HEART = Imaging.scale(Resources.images().get("src/main/resources/hud/life.png"), 5.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the resources folder is configured correctly for your project, you only need to specify the file name, not the entire relative path.
private static final BufferedImage HEARTEMPTY = Imaging.scale(Resources.images().get("src/main/resources/hud/herzleer.png"), 5.0); | ||
|
||
//optional / intialize a Padding variable, to change positioning easier later on | ||
private static final int PADDING = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One could also use values that are relative to the screen resolution in order to make the UI more dynamic.
|
||
import de.gurkenlabs.litiengine.Game; | ||
import de.gurkenlabs.litiengine.gui.screens.GameScreen; | ||
import java.awt.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcard import.
} | ||
@Override | ||
public void render(Graphics2D g) { | ||
super.render(g); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to override the render
method here.
This is exactly what the parent render method in the GameScreen class does.
Co-authored-by: Matthias <[email protected]>
Co-authored-by: Matthias <[email protected]>
Co-authored-by: Matthias <[email protected]>
Co-authored-by: Matthias <[email protected]>
Co-authored-by: Matthias <[email protected]>
Co-authored-by: Matthias <[email protected]>
Just checking in whether you're planning to implement my suggestions :) |
wrote a new documentation on how to implement a HUD with an Healthbar as an example