
import { _decorator, math, Component, resources, Texture2D, Sprite, UITransform } from 'cc';
import { Animation, AnimationClip, SpriteAtlas, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

import { RoleSprite } from './RoleSprite';
 
@ccclass('mainScene')
export class mainScene extends Component {
    
    start () {
        let thisSelf = this;
        let resList: string = "map/test1/texture";        
        resources.load(resList, Texture2D, function(error, asset: Texture2D): void {
            if(!error){
                thisSelf.updateSceneData(asset);
            }
            else console.log(error.message);
        }); 

        let role = new RoleSprite();
        role.onLoad(this.node.getChildByName("roleNode"));
    }

    private updateSceneData(background: Texture2D): void {
        let bk = this.node.getChildByName("background");
        let sprite = bk.getComponent(Sprite);
        let spriteFrame = new SpriteFrame();
        spriteFrame.texture = background;
        sprite.spriteFrame = spriteFrame;
    }
}