// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        UpLeft: {
            default: null,       
            type: cc.Sprite,
            serializable: true,  
        },
        UpRight:{
            default: null,       
            type: cc.Sprite,
            serializable: true,  
        },
        DownLeft:{
            default: null,       
            type: cc.Sprite,
            serializable: true,  
        },
        DownRight:{
            default: null,       
            type: cc.Sprite,
            serializable: true,  
        },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
       GlobalD.GameImage = this;

        // //读取背景图片
        // if(!this.BG_UpLeft){
        //     this.onLoadingImage('resUI/BG_UpLeft',this._setBG_UpLeft)
        // }
        // if(!this.BG_UpRight){
        //     this.onLoadingImage('resUI/BG_UpRight',this._setBG_UpRight)
        // }
        // if(!this.BG_DownLeft){
        //     this.onLoadingImage('resUI/BG_DownLeft',this._setBG_DownLeft)
        // }
        // if(!this.BG_DownRight){
        //     this.onLoadingImage('resUI/BG_DownRight',this._setBG_DownRight)
        // }
    },

    start () {

 
    },

    //读取背景图像左上
    _setBG_UpLeft(res,self){
        self.UpLeft.spriteFrame = res;
    },
    //读取背景图像右上
    _setBG_UpRight(res,self){
        self.UpRight.spriteFrame = res;
    },
    //读取背景图像左下
    _setBG_DownLeft(res,self){
        self.DownLeft.spriteFrame = res;
    },
    //读取背景图像右下
    _setBG_DownRight(res,self){
        self.DownRight.spriteFrame =res;
    },
    // update (dt) {},

    onSetTargetSprite(){

    },
    onLoadingImage(url,callBack){
        let self = this;
        cc.loader.loadRes(url,cc.SpriteFrame,function(err,texture){
            // cc.log('成功加载图片'+texture.name);
            callBack(texture,self)
        }.bind(this))
    }
});
