Bitmap.hx 709 B

123456789101112131415161718192021222324252627
  1. package h2d;
  2. class Bitmap extends Drawable {
  3. public var tile : Tile;
  4. public function new( ?tile : Tile, ?parent : h2d.Sprite ) {
  5. super(parent);
  6. this.tile = tile;
  7. }
  8. override function set_tileWrap(b) {
  9. if( b && tile != null && tile.getTexture().flags.has(IsNPOT) )
  10. throw "Cannot set tileWrap on a non power-of-two texture";
  11. return tileWrap = b;
  12. }
  13. override function getBoundsRec( relativeTo : Sprite, out : h2d.col.Bounds, forSize : Bool ) {
  14. super.getBoundsRec(relativeTo, out, forSize);
  15. if( tile != null ) addBounds(relativeTo, out, tile.dx, tile.dy, tile.width, tile.height);
  16. }
  17. override function draw( ctx : RenderContext ) {
  18. emitTile(ctx,tile);
  19. }
  20. }