Hello world source code

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



2. Add the follwing code to the class.

import pulpcore.scene.Scene2D;
import pulpcore.image.CoreFont;
import pulpcore.image.CoreGraphics;
import pulpcore.sprite.Label;
import pulpcore.sprite.Sprite;
import pulpcore.sprite.FilledSprite;
 
public class PulpcoreDemo extends Scene2D
{
   Label helloWorld;
   FilledSprite background;
 
   public void load()
   {
      //Create a background
      background = new FilledSprite(CoreGraphics.BLUE);
      add(background);
 
      //Build a new label
      helloWorld = new Label(CoreFont.getSystemFont(),
      "Hello World!", 200, 200);
 
      //Make the label nice and centered
      helloWorld.setAnchor(Sprite.HCENTER | Sprite.VCENTER);
 
      //Add the label to the scene so it will be rendered
      add(helloWorld);
   }
 
   public void update(int elapsedTime)
   {
      //Nothing is needed here today!	
   }
}

Previous
Next