Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Graphical Entities

Every sprite, shape, text, etc are entities displayable in the viewer. They implement diverse methods to be manipulated:

  • Position
  • Rotation
  • Anchor
  • Scale
  • Opacity
  • Z index

Examples

Creating a circle

// Creates a green circle
Circle circle = graphicEntityModule.createCircle()
			.setRadius(50)
			.setLineWidth(0)
			.setFillColor(0x00FF00);

Moving a circle

MyPlayer player = gameManager.getPlayer(turn % 2);
circle
	.setX(player.getX())
	.setY(player.getY());

With a Curve

circle
	.setX(player.getX(), Curve.LINEAR)
	.setY(player.getY(), Curve.LINEAR);

Creating a group of sprites

Sprite planet1 = graphicEntityModule.createSprite()
				.setImage("planet")
				.setX(-20);
Sprite planet2 = graphicEntityModule.createSprite()
				.setImage("planet")
				.setX(30);
				.setY(-10);
Sprite planet3 = graphicEntityModule.createSprite()
				.setImage("planet")
				.setY(20);

// The planets are around the point (960,540).
Group system = graphicEntityModule.createGroup(planet1, planet2, planet3)
					.setX(960)
					.setY(540);

Spinning a group of spinning sprites around a point

	planet1.setRotation(planet1.getRotation() - Math.PI / 4);
	planet2.setRotation(planet2.getRotation() + Math.PI);
	planet3.setRotation(planet3.getRotation() + Math.PI / 16);
	
	system.setRotation(system.getRotation() + Math.PI / 2);
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content