Class | Joyau::Sprite |
In: |
Drawable.cpp
|
Parent: | Joyau::Drawable |
This drawable represents an image. You can do lots of manipulations, like showing an animated sprite.
LEFT | = | INT2FIX(Sprite::LEFT) |
RIGHT | = | INT2FIX(Sprite::RIGHT) |
UP | = | INT2FIX(Sprite::UP) |
DOWN | = | INT2FIX(Sprite::DOWN) |
UP_LEFT | = | INT2FIX(Sprite::UP_LEFT) |
UP_RIGHT | = | INT2FIX(Sprite::UP_RIGHT) |
DOWN_LEFT | = | INT2FIX(Sprite::DOWN_LEFT) |
DOWN_RIGHT | = | INT2FIX(Sprite::DOWN_RIGHT) |
Creates a Sprite.
/* call-seq: new() new(filename) Creates a Sprite. */ VALUE wrap<Sprite>(int argc, VALUE *argv, VALUE info) { Sprite *ptr = new Sprite; VALUE tdata; if (argc >= 1) { try { ptr->setPicture(StringValuePtr(argv[0])); } catch (const RubyException &e) { e.rbRaise(); } } tdata = Data_Wrap_Struct(info, 0, wrapped_free<Sprite>, ptr); return tdata; }
Sets the autoDir value. When true, the sprite’s direction changes according to its moves.
/* Sets the autoDir value. When true, the sprite's direction changes according to its moves. */ VALUE Sprite_setAutoDir(VALUE self, VALUE val) { Sprite &ref = getRef<Sprite>(self); ref.setAutoDir(val == Qtrue); return val; }
Returns the sprite’s transparency.
/* Returns the sprite's transparency. */ VALUE Sprite_getAlpha(VALUE self) { Sprite &item = getRef<Sprite>(self); return INT2FIX(item.getAlpha()); }
Returns the sprite’s angle.
/* Returns the sprite's angle. */ VALUE Sprite_getAngle(VALUE self) { Sprite &item = getRef<Sprite>(self); return INT2FIX(item.getAngle()); }
Returns the sprite’s direction.
/* Returns the sprite's direction. */ VALUE Sprite_getDirection(VALUE self) { Sprite &item = getRef<Sprite>(self); return INT2FIX(item.getDirection()); }
Returns the sprite’s zoom.
/* Returns the sprite's zoom. */ VALUE Sprite_getZoom(VALUE self) { Sprite &item = getRef<Sprite>(self); return INT2FIX(item.getZoom()); }
Returns the sprite’s picture name.
/* Returns the sprite's picture name. */ VALUE Sprite_picture(VALUE self) { Sprite &ref = getRef<Sprite>(self); return rb_str_new2(ref.getPicName().c_str()); }
Saves the sprite in a file.
/* call-seq: saveFile(filename) Saves the sprite in a file. */ VALUE Sprite_saveFile(VALUE self, VALUE pic) { Sprite &item = getRef<Sprite>(self); const char *file = StringValuePtr(pic); item.saveImage(file); return Qnil; }
Sets the sprite’s transparency.
/* call-seq: setAlpga(val) Sets the sprite's transparency. */ VALUE Sprite_setAlpha(VALUE self, VALUE alpha) { Sprite &item = getRef<Sprite>(self); item.setAlpha(FIX2INT(alpha)); return alpha; }
Sets the sprite’s angle.
/* call-seq: setAngle(val) Sets the sprite's angle. */ VALUE Sprite_setAngle(VALUE self, VALUE angle) { Sprite &item = getRef<Sprite>(self); item.setAngle(FIX2INT(angle)); return angle; }
Sets how many animation steps there are in the sprite. This considers that each step has the same size.
/* call-seq: setAnimation(x, y) Sets how many animation steps there are in the sprite. This considers that each step has the same size. */ VALUE Sprite_setAnimation(VALUE self, VALUE nbrX, VALUE nbrY) { Sprite &item = getRef<Sprite>(self); item.setAnimation(FIX2INT(nbrX), FIX2INT(nbrY)); return Qnil; }
Sets how many frame the sprite should stay on the same animation.
/* call-seq: setAnimTime(frames) Sets how many frame the sprite should stay on the same animation. */ VALUE Sprite_setAnimationTime(VALUE self, VALUE t) { Sprite &item = getRef<Sprite>(self); item.setAnimationTime(FIX2INT(t)); return t; }
Sets the sprite’s direction.
/* call-seq: setDirection(dir) Sets the sprite's direction. */ VALUE Sprite_setDirection(VALUE self, VALUE dir) { Sprite &item = getRef<Sprite>(self); item.setDirection(FIX2INT(dir)); return dir; }
Sets the sprite’s file. Notice that the same picture won’t be loaded twice: all the sprites will share that ressource.
/* call-seq: setPicture(pic) Sets the sprite's file. Notice that the same picture won't be loaded twice: all the sprites will share that ressource. */ VALUE Sprite_setPicture(VALUE self, VALUE pic) { Sprite &item = getRef<Sprite>(self); try { item.setPicture(StringValuePtr(pic)); } catch(const RubyException &e) { e.rbRaise(); } return pic; }
Sets the rect which is shown.
/* call-seq: setTile(x, y, w, h) Sets the rect which is shown. */ VALUE Sprite_setTile(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) { Sprite &item = getRef<Sprite>(self); item.setTile(FIX2INT(x), FIX2INT(y), FIX2INT(w), FIX2INT(h)); return Qnil; }
Converts the sprite in a buffer.
/* Converts the sprite in a buffer. */ VALUE Sprite_to_buf(VALUE self)