Modifying images?


#1

I’m trying to change properties of the image to change it’s angle, flip it, etc and I’ve read here: http://useflashpunk.net/docs/net/flashpunk/graphics/Image.html but I can’t figure out how to make it work.

I tried modifying the PLAYER_IMAGE with .flipped = true, angle = 40, etc but the image doesn’t change.
I tried the same with graphic but it gets an error and I can’t run it.

package 
{
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image; 
	import net.flashpunk.utils.Input;
	import net.flashpunk.utils.Key;
	
	public class GameEntity extends Entity
	{
		[Embed(source = "assets/sprites/player.png")] private const PLAYER_IMAGE:Class;
		
		public function GameEntity()
		{	
			graphic = new Image(PLAYER_IMAGE);
			
                        //PLAYER_IMAGE.flipped = true;

			setHitbox(24, 32);
			type = "player";
		}
}

(Martí Angelats i Ribera) #2

What you have to do is to save an instance of it as Image.

public class GameEntity extends Entity
{
	[Embed(source = "assets/sprites/player.png")] private const PLAYER_IMAGE:Class;
	
	public function GameEntity()
	{	
		var playerImg:Image = new Image(PLAYER_IMAGE);
		graphic = playerImg;
		
		playerImg.flipped = true;
		//etc.
		
		setHitbox(24, 32);
		type = "player";
	}
}

graphic's class is Graphic; not Image. You can cast it doing

(graphic as Image).flipped = true;

But it seems that you’ll make a lot of madifications so i recomend that first option.