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.

Methods

alpha   alpha=   angle   angle=   autoDir=   dir   dir=   direction   direction=   getAlpha   getAngle   getDirection   getZoom   new   picture   picture=   saveFile   setAlpha   setAngle   setAnim   setAnimTime   setDirection   setPicture   setTile   to_buf   unTile   zoom  

Constants

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)

Public Class methods

Creates a Sprite.

[Source]

/*
  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;
}

Public Instance methods

alpha()

Alias for getAlpha

alpha=(p1)

Alias for setAlpha

angle()

Alias for getAngle

angle=(p1)

Alias for setAngle

Sets the autoDir value. When true, the sprite’s direction changes according to its moves.

[Source]

/*
  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;
}
dir()

Alias for getDirection

dir=(p1)

Alias for setDirection

direction()

Alias for getDirection

direction=(p1)

Alias for setDirection

Returns the sprite’s transparency.

[Source]

/*
  Returns the sprite's transparency.
*/
VALUE Sprite_getAlpha(VALUE self)
{
   Sprite &item = getRef<Sprite>(self);

   return INT2FIX(item.getAlpha());
}

Returns the sprite’s angle.

[Source]

/*
  Returns the sprite's angle.
*/
VALUE Sprite_getAngle(VALUE self) 
{
   Sprite &item = getRef<Sprite>(self);

   return INT2FIX(item.getAngle()); 
}

Returns the sprite’s direction.

[Source]

/*
  Returns the sprite's direction.
*/
VALUE Sprite_getDirection(VALUE self) 
{ 
   Sprite &item = getRef<Sprite>(self);

   return INT2FIX(item.getDirection()); 
}

Returns the sprite’s zoom.

[Source]

/*
  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.

[Source]

/*
  Returns the sprite's picture name.
*/
VALUE Sprite_picture(VALUE self)
{
   Sprite &ref = getRef<Sprite>(self);
   return rb_str_new2(ref.getPicName().c_str());
}
picture=(p1)

Alias for setPicture

Saves the sprite in a file.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  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.

[Source]

/*
  Converts the sprite in a buffer.
*/
VALUE Sprite_to_buf(VALUE self) 

Disable the tilling effect.

[Source]

/*
  Disable the tilling effect.
 */
VALUE Sprite_unTile(VALUE self)
{
   Sprite &ref = getRef<Sprite>(self);
   ref.unTile();

   return Qnil;
}

Increase or decrease the zooming level.

[Source]

/*
  call-seq: zoom(val)

  Increase or decrease the zooming level.
*/
VALUE Sprite_zoom(VALUE self, VALUE val)
{
   Sprite &item = getRef<Sprite>(self);
   item.zoom(FIX2INT(val));
   
   return Qnil; 
}

[Validate]