import { Item } from "./Item";
import { MySprite } from './Unit';

export class Backagroud extends Item{

    pic : MySprite;

    set x(x){
        super._x = x;

        if(this.pic){
            this.pic.x = super._x;
        }
    }

    set y(y){
        super._y = y;

        if(this.pic){
            this.pic.y = super._x;
        }
    }


    init(bgPicName){

        let s = Math.max(this.scaleX, this.scaleY);
        
        const pic = new MySprite();
        pic.init(this.images.get(bgPicName));
        pic.setScaleXY(s);
        pic.x = super.x;
        pic.y = super.y;

        this.pic = pic;
    }
}