Can you use entities without graphics? [Solved]


(Darrin) #1

Fixed: Two Issues. 1) World.update() didn’t have super.update(). 2) FlashDevelop’s trace broke.

I thought this was possible but for some reason Input is not working without graphics. Hit box is set up. It works fine with a graphic but take out the graphic and nothing. Any suggestions?

package entities 

{ import net.flashpunk.Entity; import net.flashpunk.utils.Input;

/**
 * ...
 * @author Darrin Adams
 */
public class Cup extends Entity
{
	private var bClick:Boolean = false;			
	
	public function Cup() 
	{
		
		this.x = 0;
		this.y = 0;			
		setHitbox(100, 100, 0, 0);			
		
		this.visible = true;


	}
	
	public function click():Boolean 
	{
		if (bClick) 
		{				
			bClick = false;
			return true;
		}
		else 
			return bClick;
	}
	
	override public function update():void
	{	
		if (!visible)
			return;
		
		super.update();
		
		if (collidePoint(this.x, this.y, Input.mouseX, Input.mouseY)) 
		{
			if (Input.mouseDown) 
			{
				//Press					
				trace("press");
				bClick = true;					
			} 
			else 
			{
				//Mouseover
				trace("mouseover");
				
			}								
		} 
		else 
		{
			// Up with no mouseover
			
		}
		
	}
}

}


(Bora Kasap) #2

try collidePoint(0, 0, Input.mouseX, Input.mouseY);


(Darrin) #3

No change with collide point(0,0,…


(Jacob Albano) #4

Input.mouseX/mouseY return screen coordinates. Try using world.mouseX/mouseY. Passing 0, 0 as the first parameters won’t help you here.

Entities definitely work without graphics, so try enabling the developer console to see where your hitboxes are lining up.


(Darrin) #5

Thanks guys!

hmm, my trace seems to be broken. wtf flashdevelop. I had it remove itself and and that worked. now to figure out trace…

Darrin