本文整理汇总了C++中Sprite::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::GetHeight方法的具体用法?C++ Sprite::GetHeight怎么用?C++ Sprite::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Explosion
void
Game::SpawnExplosion(int x, int y)
{
Sprite* aS = m_pBackBuffer->CreateSprite("assets\\explosion.png");
// create an explosion object
Explosion* explosion = new Explosion();
// initialize the texture
if (!explosion->Initialise(*aS->GetTexture())) {
LogManager::GetInstance().Log("Explosion Init Fail!");
return;
}
// set the width and speed of the animation
int fw = aS->GetWidth() / 5;
explosion->SetFrameWidth(fw); // 5 frames in the animation
explosion->SetFrameSpeed(0.1f);
for (int i = 0; i < 5; i++) {
explosion->AddFrame(i * fw);
}
// set the center points for visual alignment
explosion->SetCenter(fw / 2, aS->GetHeight() / 2);
// set the x and y
explosion->SetX(x - explosion->GetCenterX() / 2);
explosion->SetY(y - explosion->GetCenterY() / 2);
// add to the explosion container
m_explosion.push_back(explosion);
}
示例2: GetHeight
uint16 WorkerActor::GetHeight(void) const
{
Assert(m_unitSpriteGroup != NULL);
if (m_unitSpriteGroup == NULL) return 0;
Sprite * theSprite = m_unitSpriteGroup->GetGroupSprite((GAME_ACTION)m_curUnitAction);
return (theSprite) ? theSprite->GetHeight() : 0;
}
示例3: GetSize
Vector2 Animation::GetSize()
{
// To get the size of the animation, we'll just get the size of the first frame.
// If other frames are different sizes, then the concept of a size for the animation itself
// is meaningless, so we don't really care about that part.
Sprite *pFirstFrameSprite = frameList[0]->GetSprite();
return Vector2(pFirstFrameSprite->GetWidth(), pFirstFrameSprite->GetHeight());
}
示例4: DrawBulletsRemaining
void DrawBulletsRemaining(Weapon* DrawMe, int timediff)
{
Sprite* BulletSprite;
Sprite* MySprite;
Bullet* TheBullet;
char* Name = "INVALID BULLETS";
RECT Client;
GetClientRect(TheDisplay.GetHWnd(), &Client);
TheBullet = GetGlobalBulletData(DrawMe->mBulletID);
if(!TheBullet)
return;
Name = TheBullet->mName;
BulletSprite = GetGlobalSpriteData(TheBullet->mFullBulletSpriteID);
if(!BulletSprite)
return;
MySprite = new Sprite;
MySprite->InitializeSpriteCopy(BulletSprite);
POINT FontOrigin;
FontOrigin.x = Client.right - DrawMe->mMaxRounds * BulletSprite->GetWidth();
int StrWidth = GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetStringWidth(Name);
if(FontOrigin.x + StrWidth > Client.right)
FontOrigin.x -= (FontOrigin.x + StrWidth) - Client.right + 20;
FontOrigin.y = Client.bottom - BulletSprite->GetHeight() - GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetCharHeight() - 5;
int FullWidth = DrawMe->mCurrentRounds * BulletSprite->GetWidth();
if(FullWidth > Client.right - Client.left)
return;
GameWeaponSelector.BulletName->SetLoc(FontOrigin);
GameWeaponSelector.BulletName->SetWidth(Client.right - Client.left);
int FullHeight = BulletSprite->GetHeight();
POINT Loc;
Loc.x = Client.right - FullWidth;
Loc.y = Client.bottom - FullHeight;
for(int i = 0; i < DrawMe->mCurrentRounds; i++)
{
MySprite->SetLoc(Loc);
MySprite->Draw(TheDisplay);
Loc.x += BulletSprite->GetWidth();
}
GameWeaponSelector.BulletName->Update(timediff);
GameWeaponSelector.BulletName->Draw(TheDisplay);
delete MySprite;
}
示例5: DrawSprite
void BackBuffer::DrawSprite(Sprite& sprite)
{
SDL_Rect dest;
dest.x = sprite.GetX();
dest.y = sprite.GetY();
dest.w = sprite.GetWidth();
dest.h = sprite.GetHeight();
SDL_RenderCopy(m_pRenderer, sprite.GetTexture()->GetTexture(), 0, &dest);
}
示例6: GetHeight
uint16 EffectActor::GetHeight(void) const
{
Assert(m_effectSpriteGroup);
if (!m_effectSpriteGroup) return 0;
Sprite * theSprite = m_effectSpriteGroup->GetGroupSprite((GAME_ACTION)m_curEffectAction);
if (!theSprite && (m_curEffectAction != EFFECTACTION_PLAY))
{
theSprite = m_effectSpriteGroup->GetGroupSprite((GAME_ACTION)EFFECTACTION_PLAY);
}
return theSprite ? theSprite->GetHeight() : 0;
}
示例7: GetHeight
uint16 TradeActor::GetHeight(void)
{
Assert(m_goodSpriteGroup != NULL);
if (m_goodSpriteGroup == NULL) return 0;
Sprite *theSprite;
theSprite = m_goodSpriteGroup->GetGroupSprite((GAME_ACTION)m_curGoodAction);
if (theSprite != NULL) {
return theSprite->GetHeight();
} else {
return 0;
}
}
示例8: Redo
void ActionSetVisibilityPoint::Redo()
{
Sprite* visibilityToolSprite = visibilityToolProxy->GetSprite();
RenderManager::Instance()->SetRenderTarget(visibilityToolSprite);
RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
cursorSprite->SetPosition(redoVisibilityPoint - cursorSprite->GetSize() / 2.f);
cursorSprite->Draw();
RenderManager::Instance()->RestoreRenderTarget();
visibilityToolProxy->UpdateVisibilityPointSet(true);
visibilityToolProxy->UpdateRect(Rect(0.f, 0.f, visibilityToolSprite->GetWidth(), visibilityToolSprite->GetHeight()));
visibilityToolProxy->SetVisibilityPoint(redoVisibilityPoint);
}
示例9: ApplyAjustedSize
ControlsPositionData ControlsAdjustSizeCommand::ApplyAjustedSize(HierarchyTreeController::SELECTEDCONTROLNODES& controls)
{
ControlsPositionData resultData;
for (HierarchyTreeController::SELECTEDCONTROLNODES::iterator iter = controls.begin(); iter != controls.end(); ++iter)
{
HierarchyTreeControlNode* control = (*iter);
UIControl* uiControl = control->GetUIObject();
int32 nodeId = control->GetId();
if (uiControl)
{
// Get sprite
Sprite* sprite = uiControl->GetSprite();
Rect prevRect = uiControl->GetRect();
Rect updatedRect = prevRect;
if (sprite)
{
// Save control size data for undo
resultData.AddControl(uiControl);
// Set new size of updated rect
updatedRect.dx = sprite->GetWidth();
updatedRect.dy = sprite->GetHeight();
BaseMetadata* baseMetadata = GetMetadataForTreeNode(nodeId);
// This command is NOT state-aware and contains one and only param.
baseMetadata->SetActiveParamID(0);
baseMetadata->ApplyResize(prevRect, updatedRect);
SAFE_DELETE(baseMetadata);
}
}
}
return resultData;
}
示例10: SetStretchCapMaxValues
void BackGroundPropertyGridWidget::SetStretchCapMaxValues()
{
WidgetSignalsBlocker blocker(ui->drawTypeComboBox);
// Get current drawType combo value
int selectedIndex = ui->drawTypeComboBox->currentIndex();
UIControlBackground::eDrawType drawType = BackgroundGridWidgetHelper::GetDrawType(selectedIndex);
// Set default values
int horizontalStretchMax = 999;
int verticalStretchMax = 999;
// For DRAW_TILED option we should set horizontal and vertical stretch maximum values
// Tiling the sprite to more than half of its size have no sence
if (drawType == UIControlBackground::DRAW_TILED)
{
QString spriteName = ui->spriteLineEdit->text();
if (!spriteName.isEmpty())
{
Sprite* sprite = Sprite::Create(spriteName.toStdString());
if (sprite)
{
// Get sprite's active size
float32 texDx = sprite->GetWidth();
float32 texDy = sprite->GetHeight();
// Calculate maximum stretch values
horizontalStretchMax = texDx / 2 - 1;
verticalStretchMax = texDy / 2 - 1;
}
SafeRelease(sprite);
}
}
ui->lrSpinBox->setMaximum(horizontalStretchMax);
ui->tbSpinBox->setMaximum(verticalStretchMax);
}
示例11: if
Character::Character(int aNumberOfLimbs, glm::vec2 aRangeOfLimbSize, glm::vec2 aRangeOfStats, glm::vec2 aPosition, bool aIsPlayer)
{
m_SwingLeft = false;
m_Timer = nullptr;
m_DamageTimer = nullptr;
m_Destroyed = false;
m_DestroyPlayer = false;
m_SlatedForDestruction = false;
m_Health = DEFAULT_HEALTH;
m_Strength = DEFAULT_STRENGTH;
m_Speed = DEFAULT_SPEED;
m_IsPlayer = aIsPlayer;
m_NumberOfLimbs = aNumberOfLimbs;
bool leftArm = true;
bool leftLeg = true;
string limbType;
Random* random = new Random();
for(float i = 0; i < m_NumberOfLimbs; i++)
{
//TODO: Fine tune the positioning based off of image size
//Assume all characters face the same direction on spawn
vec2 position = aPosition;
random->RandomizeSeed();
//TODO: Make a local variable, give it a 1% chance of becoming a second head. If it is, set the local variable to i, i to 1 (for head), make the head, then set i to the local variable
if (i == 0)
{
//Torso, do nothing
if(m_IsPlayer == true)
limbType = "CharTorso"; //TODO: Make these constants
else
limbType = "DemonTorso";
}
else if (i == 1)
{
//Gives visibility to the body better. Decide if we want to do this
position.y -= 2;
if(m_IsPlayer == true)
limbType = "CharHead";
else
limbType = "DemonHead";
}
else
{
if ((int)i % 2 == 0)
{
if (leftArm == true)
{
position.x -= 16;
if(m_IsPlayer == true)
limbType = "CharArmLeft";
else
limbType = "DemonArmLeft";
}
else
{
position.x += 16;
if(m_IsPlayer == true)
limbType = "CharArmRight";
else
limbType = "DemonArmRight";
}
position.y += i;// / m_NumberOfLimbs;
leftArm = !leftArm;
}
else
{
if (leftLeg == true)
{
position.x -= 8; //TODO: Change this to be based on the image width of m_Limbs.at(0)
if(m_IsPlayer == true)
limbType = "CharLegLeft";
else
limbType = "DemonLegLeft";
}
else
{
position.x += 8;
if(m_IsPlayer == true)
limbType = "CharLegRight";
else
limbType = "DemonLegRight";
}
position.y -= 16;
leftLeg = !leftLeg;
}
}
Sprite* sprite = new Sprite(limbType);
glm::vec2 size = glm::vec2(sprite->GetWidth(), sprite->GetHeight());
//.........这里部分代码省略.........
示例12: LabeledSprite
void LabeledSprite(GameManager *mgr, uint32 marker_handle, uint32 width, uint32 height)
{
Sprite *image = new Sprite(mgr);
image->SetImage(mgr->GetResourceManager()->GetImage(ARROW_HANDLE));
image->AddTransformation(new AnchorTransformation());
image->SetBaseLocation(CIwVec2(mgr->GetSurfaceWidth() / 2, mgr->GetSurfaceHeight() / 2));
OrbitTransformation *orbiter = new OrbitTransformation(150, 5000, 0, CounterClockwise);
image->AddTransformation(orbiter);
mgr->RegisterGameObject(image);
TextSprite *text = new TextSprite(mgr, (char *)"Normal");
text->AddTransformation(new AnchorTransformation());
text->AddTransformation(new AnchorToTransformation(image, image, (float)(text->GetHeight() / 2 + image->GetHeight() / 2 + 10), 0, RelativeToNormal));
text->AddTransformation(new OrientToTransformation((IDirectional*)image, OrientAlongOrientation));
mgr->RegisterGameObject(text);
}
示例13: Start
void Sample::Start()
{
cache_ = GetSubsystem<ResourceCache>();
ui_ = GetSubsystem<UI>();
graphics_ = GetSubsystem<Graphics>();
//////////////////////////////////////////////////////////////////////////
// Get default styles
XMLFile* styleFile = cache_->GetResource<XMLFile>("UI/DefaultStyle.xml");
ui_->GetRoot()->SetDefaultStyle(styleFile);
// create main ui
rootUI_ = ui_->GetRoot()->CreateChild<UIElement>("IDERoot");
rootUI_->SetSize(ui_->GetRoot()->GetSize());
rootUI_->SetTraversalMode(TM_DEPTH_FIRST); // This is needed for root-like element to prevent artifacts
rootUI_->SetDefaultStyle(styleFile);
//////////////////////////////////////////////////////////////////////////
/// Create console
console_ = engine_->CreateConsole();
console_->SetDefaultStyle(styleFile);
//////////////////////////////////////////////////////////////////////////
/// Create debug HUD.
debugHud_ = engine_->CreateDebugHud();
debugHud_->SetDefaultStyle(styleFile);
//////////////////////////////////////////////////////////////////////////
/// Subscribe key down event
SubscribeToEvent(E_KEYDOWN, HANDLER(Sample, HandleKeyDown));
// edit clear color, set background color
Renderer* renderer = GetSubsystem<Renderer>();
Zone* zone = renderer->GetDefaultZone();
zone->SetFogColor(Color(0.3f, 0.3f, 0.4f)); // Set background color for the scene
//////////////////////////////////////////////////////////////////////////
/// Create Cursor
// Cursor* cursor_ = new Cursor(context_);
// cursor_->SetStyleAuto(styleFile);
// ui_->SetCursor(cursor_);
// if (GetPlatform() == "Android" || GetPlatform() == "iOS")
// ui_->GetCursor()->SetVisible(false);
/// Show Platform Cursor
Input* input = GetSubsystem<Input>();
input->SetMouseVisible(true);
//////////////////////////////////////////////////////////////////////////
/// create an svg image
rootUI_->AddChild(CreateSVGSprite("GameData/svg/23.svg"));
Sprite* drawing = CreateSVGSprite("GameData/svg/drawing.svg");
if (drawing)
{
// Set logo sprite hot spot
drawing->SetHotSpot(0, drawing->GetHeight());
drawing->SetAlignment(HA_LEFT, VA_BOTTOM);
rootUI_->AddChild(drawing);
}
Sprite* nano = CreateSVGSprite("GameData/svg/nano.svg");
if (nano)
{
// Set logo sprite hot spot
nano->SetHotSpot(0, -nano->GetHeight());
nano->SetAlignment(HA_LEFT, VA_TOP);
rootUI_->AddChild(nano);
}
}
示例14: Loop
void Game::Loop()
{
// Splash screen
SDL_Surface* sdl_surface = m_screen->GetSDLSurface();
SDL_FillRect(sdl_surface, 0, SDL_MapRGB(sdl_surface->format, 101, 192, 49));
Sprite* sprite = Sprite::CreateFromTexture(*m_gfx_manager, "splash");
sprite->Render(*m_screen, (m_screen->GetWidth() / 2) - (sprite->GetWidth() / 2), (m_screen->GetHeight() / 2) - (sprite->GetHeight() / 2));
SDL_Flip(sdl_surface);
SDL_Event event;
bool running = true;
bool exit = false;
unsigned int interval = 0;
m_timer->Reset();
while (running && interval < 3000)
{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
running = false;
exit = true;
break;
case SDL_KEYDOWN:
running = false;
break;
default:
break;
}
}
m_timer->Update();
interval += m_timer->GetInterval();
}
Sprite::DestroySprite(sprite);
if (!exit)
{
m_timer->Reset();
running = true;
while (running)
{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
running = false;
break;
case SDL_KEYDOWN:
// Exit game
if (event.key.keysym.sym == SDLK_ESCAPE)
{
if (m_menu)
{
running = false;
}
else
{
StartNewGame(true);
}
}
// New game
else if (event.key.keysym.sym == SDLK_F2)
{
StartNewGame(false);
}
// Pause game
else if (event.key.keysym.sym == SDLK_p)
{
if (!m_menu)
{
m_pause = !m_pause;
}
}
// Sound on/off
else if (event.key.keysym.sym == SDLK_s)
{
int volume = Mix_Volume(-1, -1);
if (volume == 0)
{
Mix_Volume(-1, MIX_MAX_VOLUME);
}
else
{
Mix_Volume(-1, 0);
}
}
// Screenshot
else if (event.key.keysym.sym == SDLK_F11)
{
m_screen->Capture();
}
break;
default:
break;
}
}
// Update
if (m_snake->IsAlive())
//.........这里部分代码省略.........
示例15: LoadResource
bool MyGame::LoadResource()
{
// Build scene graph
ContainerNode* root = new ContainerNode();
OrthographicProjectionNode* ortho = new OrthographicProjectionNode();
Texture* texTile = Texture::Get("!tile.png");
Texture* texStair = Texture::Get("!stair.png");
Font* texFont = Font::Get("!DroidSans.ttf|texture_size=256");
Cube* floor = new Cube(Vector3f(50.f, 1.f, 50.f), 50.f, "Floor");
floor->SetTexture(texTile);
root->AddChild(floor);
floor->AddToPhysic(0, Vector3f(0, -.5f, 0));
// Stair
float sw = 1.f; // stair depth
float sh = 1.0f; // stair height
for(int i = 0; i < 5; ++i)
{
Cube* stair = new Cube(Vector3f(6.f, sh, sw), 4);
stair->SetTexture(texStair);
root->AddChild(stair);
stair->AddToPhysic(0, Vector3f(0, sh / 2.f + (i * sh), 5 + (i * sw)));
}
TextNode* title = new TextNode(texFont, 12.f, "TAK game sample");
title->SetShader(Shader::Get("!nolight"));
title->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 25, 0);
ortho->AddChild(title);
TextNode* instruction = new TextNode(texFont, 12.f, "Drag and hold left mouse button to rotate, hold right mouse button to zoom");
instruction->SetShader(Shader::Get("!nolight"));
instruction->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 45, 0);
ortho->AddChild(instruction);
m_txtFps = new TextNode(texFont);
m_txtFps->SetShader(Shader::Get("!nolight"));
m_txtFps->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 65, 0);
ortho->AddChild(m_txtFps);
m_txtCubeCount = new TextNode(texFont);
m_txtCubeCount->SetShader(Shader::Get("!nolight"));
m_txtCubeCount->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 85, 0);
ortho->AddChild(m_txtCubeCount);
Cube* pc1;
// front wall
pc1 = new Cube(Vector3f(5.5f, 7.f, .5f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(0, pc1->GetSize().y / 2.f, 9.75f));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(-3, pc1->GetSize().y / 2.f, 5));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(3, pc1->GetSize().y / 2.f, 5));
// Flag engine logo
Sprite* flag = new Sprite(128, 128, Texture::Get("!engineflag.png"));
flag->SetShader(Shader::Get("!nolight"));
flag->SetPositionAbsolute(GetScene().GetParams().GetWidth() - flag->GetWidth() / 2.f, flag->GetHeight() / 2.f - 20.f, 0);
ortho->AddChild(flag);
root->AddChild(ortho);
GetScene().SetRoot(root);
// Setup camera:
Camera* camera = new LookAtCamera(Vector3f(0, 0, 5), 25.f);
GetScene().SetCamera(camera);
return true;
}