Research Article
MEnDiGa: A Minimal Engine for Digital Games
Algorithm 1
Setting up the GraphicNode of the playable character.
// Create the graphic node | SpriteNodeāāgraphicNode = new SpriteNode("bob", // sprite name | "res/superjumper/items.png", // source file path | 32, 32); // width and height of a single frame within the sheet | // Select a rectangular region of the texture | graphicNode.setRegion(0, 128, // Upper left corner position | 160, 32); // region width and height | // Defining animations | graphicNode.defineAnimation("jump", // Animation name | new int 0,1,0.2f,// Animations frame and frame delay | PlayMode.LOOP_NORMAL);// Play mode | graphicNode.setCurrentAnimation("jump"); // Set "jump" as the current animation | graphicNode.setScale(l/32f); // Set the scale as 32 pixels per game unit | this.addGraphicNode(graphicNode); // Add the sprite to the node |
|