Alex Jeffery

HomeArchivesAboutFeed

Hello world source code

1. Click the new class button on the tool bar.
Create a new class called PulpcoreDemo.

New Class

New Class

2. Add the follwing code to the class.

  1. import pulpcore.scene.Scene2D;
  2. import pulpcore.image.CoreFont;
  3. import pulpcore.image.CoreGraphics;
  4. import pulpcore.sprite.Label;
  5. import pulpcore.sprite.Sprite;
  6. import pulpcore.sprite.FilledSprite;
  7.  
  8. public class PulpcoreDemo extends Scene2D
  9. {
  10. Label helloWorld;
  11. FilledSprite background;
  12.  
  13. public void load()
  14. {
  15. //Create a background
  16. background = new FilledSprite(CoreGraphics.BLUE);
  17. add(background);
  18.  
  19. //Build a new label
  20. helloWorld = new Label(CoreFont.getSystemFont(),
  21. "Hello World!", 200, 200);
  22.  
  23. //Make the label nice and centered
  24. helloWorld.setAnchor(Sprite.HCENTER | Sprite.VCENTER);
  25.  
  26. //Add the label to the scene so it will be rendered
  27. add(helloWorld);
  28. }
  29.  
  30. public void update(int elapsedTime)
  31. {
  32. //Nothing is needed here today!
  33. }
  34. }
  35.  

Previous
Next

Alex Jeffery