Downscaling doesn't affect entities?


(John Andersson) #1

Hi.

package 
{
import net.flashpunk.Engine;
import net.flashpunk.FP;

[SWF(width="960", height="540")]
 
public class Main extends Engine
{
	
	public function Main():void 
	{
		super(1920, 1080);
		FP.screen.scale = 0.5;
	}
	
	override public function init():void 
	{
		trace("FlashPunk has started.");
		
		super.init();
		FP.world = new Level1();
	}
	
}

}

package 
{
import net.flashpunk.World;

public class Level1 extends World 
{
    public function Level1() 
	{
		for (var i:int = 0; i < 20; i++)
		{
			add(new Ground_Rock(i, 0));
			add(new Ground_Rock(i, 14));
		}
		
		for (i = 0; i < 14; i++)
		{
			add(new Ground_Rock(0, i));
			add(new Ground_Rock(19, i));
		}
		
		for (i = 1; i < 5; i++)
		{
			add(new Ground_Rock(5 - i, 14 - i));
			add(new Ground_Rock(8 + i, 5+i));
			add(new Ground_Rock(2 + i, 10 - i));
			add(new Ground_Rock(13 + i, 8 - i));
		}
    }
}
}

package  
{
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;

public class Ground_Rock extends Entity 
{
	[Embed(source="assets/rock.png")]
	
	private const GROUND:Class;
	
	public function Ground_Rock(posX:int, posY:int) 
	{
		graphic = new Image(GROUND);
		setHitbox(120, 120);
		type = "ground";
		x = posX * 120;
		y = posY * 120;
	}
	
}

}

How come the entities don’t get downscaled? They don’t show properly. I can’t see every tile.

I am following this guide: http://www.emanueleferonato.com/2011/05/25/creation-of-a-platform-game-using-flashpunk/

Thank you!

EDIT: Okay, apparently the tile generating code was simply generating beyond the screen. I’m sorry, but this thread is useless. I just didn’t understand the logic behind the code…


(Ultima2876) #2

No problem. I’ll close it for you :slight_smile:


(Ultima2876) #3