Character Position


(Nuuup Gamesssss) #1

Hello. My name is Nuuup. I am interested in using the Flashpunk engine since the start of this year. I made only one game ( until now ), which is Mr. Boo, a game for the 31st Ludum Dare and it was received quite well by audiences. I was trying to make my second game in Flashpunk today, and I haven’ t figured out how to put x and y positions in my entities. Here’ s the source code for one of the entities :

public class Slime extends Entity
{
	[Embed(source = "../../assets/Slime.png")] private const SLIME:Class;
	
	public function Slime() 
	{
		
		graphic = new Image(SLIME);
	}
	
} 

Where and how do I add x and y positioning in this class ? Please help me.


(Martí Angelats i Ribera) #2

It literally already have a x and a y (they are two parameters of the Entity class). You only have to do (it’s only an example):

x = 10;
y = 200;

The constructor also have these parameters:

public class Slime extends Entity
{
	[Embed(source = "../../assets/Slime.png")] private const SLIME:Class;

	public function Slime() 
	{

		super(x, y, new Image(SLIME));
	}

}

BTW, i recomend you to do the basic toturials to start with FP.

Edit: Yeah it doesn’t require the parameters… Incorrect word for what i wanted to say XD


(Jacob Albano) #3

The constructor doesn’t technically require any parameters, since they’re all optional. They exist for convenience more than anything else. I know I rarely use them myself.