Skip to content

Commit

Permalink
A bit of refactoring, added pixelsFromLeft, pixelsFromRight.
Browse files Browse the repository at this point in the history
  • Loading branch information
asalga committed Aug 20, 2013
1 parent b3c65c4 commit 989add8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion HUDLayer.pde
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class HUDLayer implements LayerObserver{
gemsAcquired = new RetroLabel(solarWindsFont);
gemsAcquired.setHorizontalTrimming(true);
gemsAcquired.setHorizontalSpacing(2);
gemsAcquired.pixelsFromTopLeft(105, 5);
gemsAcquired.pixelsFromRight(1);
parent.addWidget(gemsAcquired);

// Time
Expand Down
32 changes: 30 additions & 2 deletions RetroPanel.pde
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class RetroPanel extends RetroWidget{
y = yPixels;
}



/*
TODO: needs debugging
*/
Expand Down Expand Up @@ -157,6 +159,31 @@ public class RetroPanel extends RetroWidget{
y = (p.h/2) - (h/2) + yPixels;
}

/*
*/
public void pixelsFromLeft(int xPixels){
RetroWidget p = getParent();

anchor = FROM_LEFT;
this.xPixels = xPixels;

x = xPixels;
y = (p.h/2) - (h/2);
}

/*
*/
public void pixelsFromRight(int xPixels){
RetroWidget p = getParent();

anchor = FROM_RIGHT;
this.xPixels = xPixels;

x = p.w - w - xPixels;
y = (p.h/2) - (h/2);
}


public void updatePosition(){
dirty = true;
}
Expand Down Expand Up @@ -191,8 +218,9 @@ public class RetroPanel extends RetroWidget{
case FROM_CENTER:pixelsFromCenter(xPixels, yPixels);break;
case FROM_BOTTOM:break;

//case FROM_LEFT: pixelsFromLeft(xPixels);break;
//case FROM_RIGHT: pixelsFromRight(xPixels);break;

case FROM_LEFT: pixelsFromLeft(xPixels);break;
case FROM_RIGHT: pixelsFromRight(xPixels);break;

case FROM_TOP_LEFT: pixelsFromTopLeft(yPixels, xPixels);break;
case FROM_TOP_RIGHT: pixelsFromTopRight(yPixels, xPixels);break;
Expand Down
2 changes: 1 addition & 1 deletion ScreenGameplay.pde
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public class ScreenGameplay implements IScreen, Subject{
pushStyle();
fill(0);
noStroke();
rect(START_X-150, -238, 250, 222);
rect(START_X-150, -222, 250, 222);
popStyle();

// Draw a box around the grid, just for debugging.
Expand Down

0 comments on commit 989add8

Please sign in to comment.