本文整理汇总了C++中CSprite::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CSprite::getWidth方法的具体用法?C++ CSprite::getWidth怎么用?C++ CSprite::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSprite
的用法示例。
在下文中一共展示了CSprite::getWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadTGASprite
// load a 32-bit RGBA TGA file into sprite 's', and add colors to the palette
// as needed so that it can be shown exactly as found in the file.
// returns nonzero on failure.
char CEGASprit::LoadTGASprite( const std::string &filename, CSprite &sprite )
{
byte *image, *base;
int x,y;
Uint16 w,h;
unsigned char r,g,b,a;
int c;
Uint8 *pixel, *maskpx;
// Look in local location than in global, if tga was not found!
if (!LoadTGA(filename, &image, w, h))
return 1;
base = image;
sprite.setSize(w, h);
sprite.createSurface( g_pVideoDriver->mp_VideoEngine->getBlitSurface()->flags, g_pGfxEngine->Palette.m_Palette );
SDL_Surface *sfc = sprite.getSDLSurface();
SDL_Surface *msksfc = sprite.getSDLMaskSurface();
if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
if(SDL_MUSTLOCK(msksfc)) SDL_LockSurface(msksfc);
pixel = (Uint8*) sfc->pixels;
maskpx = (Uint8*) msksfc->pixels;
for(y=h-1;y>=0;y--)
{
for(x=0;x<w;x++)
{
b = *image++; g = *image++; r = *image++; a = *image++;
if (a & 128)
{
c = g_pGfxEngine->Palette.getcolor(r, g, b);
if (c==-1) c = g_pGfxEngine->Palette.addcolor(r, g, b);
if (c==-1) return 1;
pixel[y*w + x] = c;
maskpx[y*w + x] = 15;
}
else
maskpx[y*w + x] = 0;
}
}
if(SDL_MUSTLOCK(msksfc)) SDL_UnlockSurface(msksfc);
if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
sprite.m_bboxX1=0;
sprite.m_bboxY1=0;
sprite.m_bboxX2=sprite.getWidth();
sprite.m_bboxY2=sprite.getHeight();
delete [] base;
return 0;
}
示例2: InitFisica
void PlayFisicaState::InitFisica() {
// inicializa a classe de física e a Box2D
Fisica = CPhysics::instance();
b2Vec2 g(0,10);
Fisica->setGravity(g);
Fisica->setConvFactor(10);
CSprite *s;
s = spriteCao;
fisicaCao = Fisica->newBoxImage(CAO_ID, //int id,
s, // CImage* sprite,
1, // float density,
1.0, // float friction,
0.0, // float restitution
false); // bool staticObj=false
fisicaCao= Fisica->newBox(WALL_ID,
s->getX(), s->getY(), // posicao
s->getWidth(), s->getHeight(), // tamanho X e Y
s->getRotation(),
1, //densidade
0.5, // float friction,
0.1, // float restitution
false); // bool staticObj=false
//b2Vec2 pos(20,0);
//Fisica->setPosition(fisicaCao, pos);
//fisicaCao->SetFixedRotation(true);
s = spriteCacador;
fisicaPiso = Fisica->newBoxImage(WALL_ID, //int id,
s, // CImage* sprite,
1, // float density,
0, // float friction,
0.5, // float restitution
true); // bool staticObj=false
//Fisica->setAngle(fisicaCao, 45);
//Fisica->setAngle(fisicaPiso, 45);
//b2Vec2 pos(spriteCao->getX()/10, 100/10);
//Fisica->setPosition(fisicaPiso, pos);
//spriteCao->xOffset(spriteCao->getX()/2);
Fisica->setDrawOffset(spriteCao->getWidth()/2, spriteCao->getHeight()/2);
}
示例3: InitFisica
void PlayFisicaState::InitFisica() {
// inicializa a classe de física e a Box2D
Fisica = CPhysics::instance();
b2Vec2 g(0,10);
Fisica->setGravity(g);
Fisica->setConvFactor(10);
CSprite *s;
#define CAO
#ifdef CAO
s = spriteCao;
fisicaCao = Fisica->newBoxImage(CAO_ID, //int id,
s, // CImage* sprite,
1, // float density,
0.2, // float friction,
0.0, // float restitution
0.5, // float linearDamping
0.5, // float angularDamping
false); // bool staticObj=false
#endif
#define COBRA
#ifdef COBRA
s = spriteCobra;
fisicaCobra = Fisica->newBoxImage(COBRA_ID, //int id,
s, // CImage* sprite,
1, // float density,
0.3, // float friction,
0.0, // float restitution
0.5, // float linearDamping
0.5, // float angularDamping
false); // bool staticObj=false
#endif
Fisica->newBox(OBSTACULO1, //int id,
s->getX() + s->getWidth()*1.4, //pos x
s->getY() , // pos y
s->getWidth()/2, // width
s->getHeight(), // height
0, // rotation
1, // float density,
0.2, // float friction,
0.5, // float restitution
0.5, // float linearDamping
0.5, // float angularDamping
false); // bool staticObj=false
Fisica->newCircle(BOLA,
s->getX() + s->getWidth(),
s->getY() + s->getHeight()+ 100,
15, // float radius
1, // float density,
1.0, // float friction,
0.5, // float restitution
0.5, // float linearDamping
0.5, // float angularDamping
false); // bool staticObj=false
CriaMapDeColisao();
b2RevoluteJointDef jointDef;
jointDef.Initialize(fisicaCobra, fisicaCao, fisicaCao->GetWorldCenter());
Fisica->world->CreateJoint(&jointDef);
}