PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

surface in EasyCE 2.0

Jacco posted this code for this topic a while back

Code:

ASurface buffer("sprites.tga");
ASprite spr1( buffer, 25, 25 );
ASprite spr2( buffer, 25, 25 );


to load 2 different images in a 50x25 tga file into two different sprites...

when I try this I get two of the same image - how do I get the buffer surface to point to the next image?
Try this:

Code:

ASurface buffer("sprites.tga");
ASprite spr1( buffer, 25, 25 );
ASprite spr2( buffer + 25, 25, 25 );


That's also the reason why there's still a sprite constructor in the Overloaded libraries that accepts a pixel pointer: Sometimes you need to point to 'buffer + 25', when you have a strip of frames.

- Jacco.
draklava · 12 Jul 2002, 16:39 UTC — access violation
Hmm - using a 64x32 pixel tga file... attempt to load via

Code:

ASurface* as = new ASurface("circles.tga",false);
ASprite* spr1 = new ASprite(32,32,as);
ASprite* spr2 = new ASprite(32,32,as+32);


gives an access violation - in your example did you mean for buffer to be an ASurface* or ASurface?

Code:

// From sprite constructor ( m_Bitmap expects ASurface* )
m_Start[y] = a_Width;
for ( int x = 0; x < a_Width; x++ )
{
if (*(m_Bitmap + x + y * m_Pitch) != 0) // ERROR HERE !
{
m_Start[y] = x;
break;
}
}