Пример #1
0
cxSprite cxSpriteCreateWithFile(cxConstChars file,cxConstChars key)
{
    cxSprite this = CX_CREATE(cxSprite);
    cxTexture texture = cxTextureFactoryLoadFile(file);
    cxSpriteSetTexture(this, texture);
    cxSpriteSetTextureKey(this, key, true);
    return this;
}
Пример #2
0
void cxSpriteSetTextureAttr(cxAny pview,cxTextureAttr attr)
{
    CX_RETURN(attr == NULL);
    cxSpriteSetTexture(pview, attr->texture);
    cxSpriteSetBoxTex(pview, attr->box);
    //
    if(cxViewZeroSize(pview)){
        cxViewSetSize(pview, attr->size);
    }
}
Пример #3
0
void cxSpriteSetTextureKey(cxAny pview,cxConstChars key,cxBool equSize)
{
    cxSprite this = pview;
    if(this->texture == NULL){
        cxTexture texture = cxTextureFactoryLoadFile(key);
        cxSpriteSetTexture(pview, texture);
    }else{
        this->texCoord = cxTextureBox(this->texture, key);
    }
    CX_ASSERT(this->texture != NULL, "sprite texture not load");
    if(equSize){
        cxViewSetSize(pview, cxTextureSize(this->texture, key));
    }
    this->cxView.isDirty = true;
}
Пример #4
0
void cxSpriteSetTextureURL(cxAny pview,cxConstChars url,cxBool useTexSize)
{
    CX_RETURN(url == NULL);
    cxSprite this = pview;
    cxUrlPath path = cxUrlPathParse(url);
    CX_RETURN(path == NULL);
    cxTexture texture = cxTextureFactoryLoadFile(path->path);
    CX_ASSERT(texture != NULL, "texture load failed %s",path->path);
    cxSpriteSetTexture(this, texture);
    //use texture size
    cxBool uts = useTexSize;
    if(path->count > 1){
        cxSpriteSetTextureKey(this, path->key, uts);
    }else if(uts){
        cxViewSetSize(this, texture->size);
    }
}