add more xSprite SDL_Rect shorthands
This commit is contained in:
parent
cc276e1c2a
commit
d1e6a1e9dc
|
@ -16,17 +16,28 @@ xSprite::xSprite(const int rgba[]){
|
|||
xSprite::xSprite(const char *url){
|
||||
this->setSurface(url);
|
||||
}
|
||||
|
||||
/** image sprite with clip */
|
||||
xSprite::xSprite(const char *url, SDL_Rect clip){
|
||||
this->setSurface(url);
|
||||
this->setClip(clip);
|
||||
}
|
||||
xSprite::xSprite(const char *url, int clip_x, int clip_y, int clip_w, int clip_h){
|
||||
this->setSurface(url);
|
||||
this->setClip(clip_x, clip_y, clip_w, clip_h);
|
||||
}
|
||||
|
||||
/** image sprite with clip and projection */
|
||||
xSprite::xSprite(const char *url, SDL_Rect clip, SDL_Rect projection){
|
||||
this->setSurface(url);
|
||||
this->setClip(clip);
|
||||
this->project(projection);
|
||||
}
|
||||
xSprite::xSprite(const char *url, int clip_x, int clip_y, int clip_w, int clip_h, int project_x, int project_y, int project_w, int project_h){
|
||||
this->setSurface(url);
|
||||
this->setClip(clip_x, clip_y, clip_w, clip_h);
|
||||
this->project(project_x, project_y, project_w, project_h);
|
||||
}
|
||||
|
||||
/** update sprite to rhb color */
|
||||
void xSprite::setSurface(const int rgba[]){
|
||||
|
@ -91,12 +102,10 @@ void xSprite::setClip(SDL_Rect clip){
|
|||
_clip = clip;
|
||||
_mutex.unlock();
|
||||
}
|
||||
/** set sprite clip */
|
||||
void xSprite::setClip(int x, int y, int w, int h){
|
||||
_mutex.lock();
|
||||
_clip = (SDL_Rect){x, y, w, h};
|
||||
_mutex.unlock();
|
||||
setClip( (SDL_Rect){x, y, w, h} );
|
||||
}
|
||||
|
||||
/** gets sprite clip */
|
||||
SDL_Rect xSprite::clip(){
|
||||
_mutex.lock();
|
||||
|
@ -111,11 +120,8 @@ void xSprite::project(SDL_Rect dest){
|
|||
_projection = dest;
|
||||
_mutex.unlock();
|
||||
}
|
||||
/** set sprite projection */
|
||||
void xSprite::project(int x, int y, int w, int h){
|
||||
_mutex.lock();
|
||||
_projection = (SDL_Rect){x, y, w, h};
|
||||
_mutex.unlock();
|
||||
project( (SDL_Rect){x, y, w, h} );
|
||||
}
|
||||
/** gets sprite projection */
|
||||
SDL_Rect xSprite::projection(){
|
||||
|
|
|
@ -19,8 +19,12 @@
|
|||
xSprite(const char *url);
|
||||
// image with default clip
|
||||
xSprite(const char *url, SDL_Rect clip);
|
||||
// image with default clip
|
||||
xSprite(const char *url, int clip_x, int clip_y, int clip_w, int clip_h);
|
||||
// image with default clip and projection
|
||||
xSprite(const char *url, SDL_Rect clip, SDL_Rect projection);
|
||||
// image with default clip and projection
|
||||
xSprite(const char *url, int clip_x, int clip_y, int clip_w, int clip_h, int project_x, int project_y, int project_w, int project_h);
|
||||
virtual ~xSprite();
|
||||
|
||||
// replace surface
|
||||
|
|
Loading…
Reference in New Issue