Offset?



  • OKAY this is not fun. I try this, oh, it goes over there! I tried that, oh, it's in the upper right hand corner! I try this other, oh, it goes up that-a way!

    What I'm making is a tower defense. All the buildings start out as 12 pixels x 12 pixels. However, when you upgrade the tower, it gets a new graphic that makes it taller.

    if (upgradePoint == 2) 
    	{
    		//this.loadGraphic("assets/images/Turret2.png", false, 12, 27); 
    		loadGraphic("assets/images/Turret2.png", false, 12, 27); 
    		//y -= 15;
    		y -= 15;
    		//height -= 15;
    		//height += 20;
    		//centerOffsets();
    		//var py:FlxPoint = new FlxPoint(x, 12);
    		//centerOffsets();
    		//width = 12;
    		//height = -12;
    		//offset.y = py.y;
    		//updateHitbox();
    	}
    

    So, to keep it in the same place, I change it's y position to match. The problem then is I can't build behind it anymore. Here's what happens.

    debug

    See the tower with the bright green box around it? That's the bounding box if nothing is changed. Where I want the bounding box to be is the bright red square on the tower. HOW do I do that?



  • Setting height and offset.y without calling updateHitbox() or centerOffsets() should be enough.
    Also I think recalculating the absolute height will be less error prone than changing it relative to the previous value.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.