当前位置: 首页>>代码示例>>C++>>正文


C++ Sprite::Draw方法代码示例

本文整理汇总了C++中Sprite::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::Draw方法的具体用法?C++ Sprite::Draw怎么用?C++ Sprite::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sprite的用法示例。


在下文中一共展示了Sprite::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

 void StatusBar::Render() {
     backgrnd.Draw(0, View::Height - backgrnd.Height, false, false, true);
     backgrnd2.Draw(0, View::Height - backgrnd.Height, false, false);
     RenderLevel();
     RenderGauge();
     RenderButtons();
 }
开发者ID:bumblabumbadit,项目名称:NoLifeStory,代码行数:7,代码来源:ClassicUI.cpp

示例2: ScenePatch

void ScenePatch(){
	bool quit = false;
	SDL_Event event;

	Sprite *bgi = new Sprite("resource\\bgi_patcher.jpg",1,1);
	Sprite *title = new Sprite("resource\\title.png",1,1);

	FONT gulim;

	float progress_total = 50;
	float progress_current = 30;

	gulim.InitFont("c:\\windows\\fonts\\gulim.ttc",12);
	gulim.SetColor(255,255,255);
	gulim.SetStyle(TTF_STYLE_BOLD);

	while(!quit){
		while(SDL_PollEvent(&event)){
			switch(event.type){
			case SDL_QUIT:
				break;
			}
		}
		{
			SDL_RenderClear(renderer);

			bgi->Draw(0,0,480,272);
			title->Draw(20,20,440,170);


			SDL_Rect rtProgressTotalFrame = {20,200,440,25};
			SDL_Rect rtProgressCurrentFrame = {20,235,440,25};
			SDL_Rect rtProgressTotal = {25,205,progress_total * 4.4,15};
			SDL_Rect rtProgressCurrent = {25,240,progress_current * 4.4,15};

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_NONE);
			SDL_SetRenderDrawColor(renderer,64,64,64,255);
			SDL_RenderFillRect(renderer,&rtProgressTotalFrame);
			SDL_RenderFillRect(renderer,&rtProgressCurrentFrame);

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);
			SDL_SetRenderDrawColor(renderer,64,255,64,196);
			SDL_RenderFillRect(renderer,&rtProgressTotal);
			SDL_RenderFillRect(renderer,&rtProgressCurrent);

			gulim.Draw(renderer,"전체 진행률",25,190);
			gulim.Draw(renderer,"현재 진행률",25,225);

			gulim.Draw(renderer,"Tank Online Patcher",343,258);

			SDL_RenderPresent(renderer);
		}

		SDL_Delay(1);
	}

	delete bgi;
}
开发者ID:pjc0247,项目名称:TankOnline,代码行数:58,代码来源:patcher.cpp

示例3: DrawFTFont

void FontUsageScreen::DrawFTFont(FTFont * ftFont, Vector2 pos, float32 fontSize)
{
	ftFont->SetSize(fontSize);
	Size2i size = ftFont->GetStringSize(singleLineString);
	Rect rect(pos.x, pos.y, (float32)size.dx, (float32)size.dy);
	RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
	//RenderManager::Instance()->DrawRect(rect);
	
//	RenderHelper::Instance()->DrawLine(Vector2(pos.x, pos.y + ftFont->GetAscender()), Vector2(pos.x + size.dx, pos.y + ftFont->GetAscender()));
	
	int32 dx = 960;
	int32 dy = 40;
	int16 * buf;
	int bsz = dx * dy;
	buf = new int16[bsz];
	memset(buf, 0, dx * dy * sizeof(int16));
	ftFont->DrawStringToBuffer(buf, dx, dy, 0, 0, 0, 0, singleLineString, true);
	Texture *tex = Texture::CreateTextFromData(FORMAT_RGBA4444, (uint8*)buf, dx, dy, "");
	delete[] buf;
	
	Sprite * ftFontSprite = Sprite::CreateFromTexture(tex, 0, 0, (float32)dx, (float32)dy);
//	if(!isMultilineEnabled)
//	{
//		textSprite->SetDefaultPivotPoint(0.0f, (float32)(font->GetBaseline() - h));
//	}

	SafeRelease(tex);
	
	ftFontSprite->SetPosition(pos.x, pos.y);
	ftFontSprite->Draw();
	SafeRelease(ftFontSprite); 
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:32,代码来源:FontUsageScreen.cpp

示例4: ApplyImageToSprite

void ModifyTilemaskCommand::ApplyImageToSprite(Image* image, Sprite* dstSprite)
{
	RenderManager::Instance()->SetRenderTarget(dstSprite);
	RenderManager::Instance()->ClipPush();
	RenderManager::Instance()->SetClip(updatedRect);
	
	eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
	eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
	RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
	
	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
											   image->GetWidth(), image->GetHeight(), false);
	Sprite* srcSprite = Sprite::CreateFromTexture(texture, 0, 0, image->GetWidth(), image->GetHeight());
	
	srcSprite->SetPosition(updatedRect.x, updatedRect.y);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	srcSprite->Draw();

	dstSprite->GetTexture()->GenerateMipmaps();

	RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);
	
	RenderManager::Instance()->ClipPop();
	RenderManager::Instance()->RestoreRenderTarget();
	
	SafeRelease(texture);
	SafeRelease(srcSprite);
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:28,代码来源:TilemaskEditorCommands.cpp

示例5: Cancel

void CommandSetVisibilityPoint::Cancel()
{
	Sprite* visibilityToolSprite = visibilityToolProxy->GetSprite();
	RenderManager::Instance()->SetRenderTarget(visibilityToolSprite);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);

	if (undoImage)
	{
		Texture* drawTexture = Texture::CreateFromData(undoImage->GetPixelFormat(),
													   undoImage->GetData(),
													   undoImage->GetWidth(),
													   undoImage->GetHeight(),
													   false);
		Sprite* drawSprite = Sprite::CreateFromTexture(drawTexture, 0, 0, undoImage->GetWidth(), undoImage->GetHeight());

		drawSprite->SetPosition(0.f, 0.f);
		drawSprite->Draw();

		SafeRelease(drawSprite);
		SafeRelease(drawTexture);

		visibilityToolProxy->UpdateRect(Rect(0.f, 0.f, undoImage->GetWidth(), undoImage->GetHeight()));
	}
	
	RenderManager::Instance()->RestoreRenderTarget();

	visibilityToolProxy->SetVisibilityPoint(undoVisibilityPoint);
	visibilityToolProxy->UpdateVisibilityPointSet(undoVisibilityPointSet);
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:29,代码来源:VisibilityCheckToolCommands.cpp

示例6: ApplyImage

void CommandSetVisibilityArea::ApplyImage(DAVA::Image *image)
{
	Sprite* visibilityToolSprite = visibilityToolProxy->GetSprite();

	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
											   image->GetWidth(), image->GetHeight(), false);
	texture->GeneratePixelesation();
	Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, image->GetWidth(), image->GetHeight());

	RenderManager::Instance()->SetRenderTarget(visibilityToolSprite);
	RenderManager::Instance()->ClipPush();
	RenderManager::Instance()->ClipRect(updatedRect);

	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	sprite->SetPosition(updatedRect.x, updatedRect.y);
	sprite->Draw();

	RenderManager::Instance()->ClipPop();
	RenderManager::Instance()->RestoreRenderTarget();

	visibilityToolProxy->UpdateRect(updatedRect);

	SafeRelease(texture);
	SafeRelease(sprite);
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:25,代码来源:VisibilityCheckToolCommands.cpp

示例7: SafeRelease

Image *LandscapeEditorHeightmap::CreateToolImage(int32 sideSize)
{
    RenderManager::Instance()->LockNonMain();
    
    Image *image = currentTool->image;
    Sprite *dstSprite = Sprite::CreateAsRenderTarget((float32)sideSize, (float32)sideSize, FORMAT_RGBA8888);
    Texture *srcTex = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), 
                                              image->GetWidth(), image->GetHeight(), false);
    Sprite *srcSprite = Sprite::CreateFromTexture(srcTex, 0, 0, (float32)image->GetWidth(), (float32)image->GetHeight());
    
    RenderManager::Instance()->SetRenderTarget(dstSprite);
    
    RenderManager::Instance()->SetColor(Color::Black());
    RenderHelper::Instance()->FillRect(Rect(0, 0, (float32)dstSprite->GetTexture()->GetWidth(), (float32)dstSprite->GetTexture()->GetHeight()));
    
    RenderManager::Instance()->SetBlendMode(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
    RenderManager::Instance()->SetColor(Color::White());
    
    srcSprite->SetScaleSize((float32)sideSize, (float32)sideSize);
    srcSprite->SetPosition(Vector2((dstSprite->GetTexture()->GetWidth() - sideSize)/2.0f, 
                                   (dstSprite->GetTexture()->GetHeight() - sideSize)/2.0f));
    srcSprite->Draw();
    RenderManager::Instance()->RestoreRenderTarget();
    
    Image *retImage = dstSprite->GetTexture()->CreateImageFromMemory();
    
    SafeRelease(srcSprite);
    SafeRelease(srcTex);
    SafeRelease(dstSprite);
    
    RenderManager::Instance()->UnlockNonMain();
    
    return retImage;
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:34,代码来源:LandscapeEditorHeightmap.cpp

示例8: DrawPrimitives

	void DrawPrimitives()
	{
		if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) )
		{
			DrawMask( m_fPercent );		// this is the "right endcap" to the life
			
			const float fChamberWidthInPercent = 1.0f/NUM_CHAMBERS;
			float fPercentBetweenStrips = 1.0f/NUM_STRIPS;
			// round this so that the chamber overflows align
			if( NUM_CHAMBERS > 10 )
				fPercentBetweenStrips = froundf( fPercentBetweenStrips, fChamberWidthInPercent );

			float fPercentOffset = fmodf( GAMESTATE->m_fSongBeat/4+1000, fPercentBetweenStrips );
			ASSERT( fPercentOffset >= 0  &&  fPercentOffset <= fPercentBetweenStrips );

			for( float f=fPercentOffset+1; f>=0; f-=fPercentBetweenStrips )
			{
				DrawMask( f );
				DrawStrip( f );
			}

		}

		m_sprFrame.Draw();

	}
开发者ID:augustg,项目名称:stepmania-3.9,代码行数:26,代码来源:LifeMeterBar.cpp

示例9: CreateToolImage

Image* HeightmapEditorSystem::CreateToolImage(int32 sideSize, const FilePath& filePath)
{
	Sprite *dstSprite = Sprite::CreateAsRenderTarget((float32)sideSize, (float32)sideSize, FORMAT_RGBA8888);
	Texture *srcTex = Texture::CreateFromFile(filePath);
	Sprite *srcSprite = Sprite::CreateFromTexture(srcTex, 0, 0, (float32)srcTex->GetWidth(), (float32)srcTex->GetHeight());
	
	RenderManager::Instance()->SetRenderTarget(dstSprite);
	
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	
	RenderManager::Instance()->SetBlendMode(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
	RenderManager::Instance()->SetColor(Color::White());
	
	srcSprite->SetScaleSize((float32)sideSize, (float32)sideSize);
	srcSprite->SetPosition(Vector2((dstSprite->GetTexture()->GetWidth() - sideSize)/2.0f,
								   (dstSprite->GetTexture()->GetHeight() - sideSize)/2.0f));
	srcSprite->Draw();
	RenderManager::Instance()->RestoreRenderTarget();
	
	Image *retImage = dstSprite->GetTexture()->CreateImageFromMemory();
	
	SafeRelease(srcSprite);
	SafeRelease(srcTex);
	SafeRelease(dstSprite);
	
	return retImage;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:27,代码来源:HeightmapEditorSystem.cpp

示例10: _drawHits

////////////////////////////////////////////////////////////
/// Draw Hits
////////////////////////////////////////////////////////////
void MainClient::_drawHits(void)
{
	if(!bulletHits.empty()){
		//Draw hits
		std::list<Sprite>::iterator iter;
		Sprite *hit;
		std::vector< std::list<Sprite>::iterator> eraser;

		for(iter = bulletHits.begin(); iter != bulletHits.end(); ++iter){
			hit = &(*iter);

			if(hit->pInfo.aniPosition == hit->pInfo.aniLength){
				//No looping so remove the hit spot
				eraser.push_back(iter);
			}
			else {
				hit->Step();
				hit->Draw();
			}


		}

		//Remove 'finished' animations
		if(!eraser.empty()){
			for(size_t k = 0; k < eraser.size();k++){
				bulletHits.erase(eraser[k]);
			}
		}
	}
}
开发者ID:ballercat,项目名称:albatross,代码行数:34,代码来源:gameclient.cpp

示例11: RestoreState

void LandscapeEditorCustomColors::RestoreState(DAVA::Image *image)
{
	Texture* texture = Texture::CreateTextFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
	Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());

	uint32 width = 0;
	uint32 height = 0;

	if (colorSprite)
	{
		width = colorSprite->GetWidth();
		height = colorSprite->GetHeight();
	}
	else
	{
		width = texSurf->GetWidth();
		height = texSurf->GetHeight();
	}

	SafeRelease(colorSprite);
	colorSprite = Sprite::CreateAsRenderTarget(width, height, FORMAT_RGBA8888);

	RenderManager::Instance()->SetRenderTarget(colorSprite);
	sprite->Draw();
	RenderManager::Instance()->RestoreRenderTarget();

	SafeRelease(sprite);
	SafeRelease(texture);

	if (IsActive())
		PerformLandscapeDraw();

	unsavedChanges = true;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:34,代码来源:LandscapeEditorCustomColors.cpp

示例12: Draw

	void Sprites::Draw(int ID, int width, int height, int x, int y)
	{
		Sprite *sprt = spriteManager[ID];
		if( !sprt ) return;

		sprt->Draw(width,height,x,y,m_pD3DSprite,&textures);
	}
开发者ID:ShadowDOg100,项目名称:2D-Engine,代码行数:7,代码来源:Sprites.cpp

示例13: DrawAll

void SpriteList::DrawAll( TCanvas *Canvas ) {
  Sprite *temp = root;
  while (temp!=0)
  {
	temp->Draw( Canvas );
	temp=temp->next;
  }
}
开发者ID:SkylineNando,项目名称:Delphi,代码行数:8,代码来源:SPRITE.CPP

示例14: Draw

void DialogCharacter::Draw(string emotionId, bool isTalking, bool shouldChangeMouth, bool isRightSide, int xOffset)
{
    if (emotionId.length() == 0)
    {
        emotionId = defaultEmotionId;
    }

    if (characterOneTimeEmotions.count(emotionId) > 0)
    {
        Video *pVideo = characterOneTimeEmotions[emotionId]->GetVideo();
        Vector2 position((isRightSide ? (double)gScreenWidth - pVideo->GetWidth() : 0) + xOffset, (double)gScreenHeight - Dialog::Height - pVideo->GetHeight());
        pVideo->Draw(position, !isRightSide, Color::White);
        return;
    }

    Sprite *pBaseSprite = GetBaseSpriteForEmotion(emotionId);
    Sprite *pEyeSprite = GetEyeSpriteForEmotion(emotionId);
    Sprite *pMouthSprite = GetMouthSpriteForEmotion(emotionId, isTalking, shouldChangeMouth);
    vector<Animation *> *pForegroundLayers = GetForegroundLayersForEmotion(emotionId);

    if (pBaseSprite != NULL)
    {
        Vector2 position((isRightSide ? gScreenWidth / 2 : 0) + xOffset, 0);

        pBaseSprite->Draw(position, Color::White, 1.0, !isRightSide);

        if (pEyeSprite != NULL)
        {
            pEyeSprite->Draw(position, Color::White, 1.0, !isRightSide);
        }

        if (pMouthSprite != NULL)
        {
            pMouthSprite->Draw(position, Color::White, 1.0, !isRightSide);
        }

        if (pForegroundLayers != NULL)
        {
            for (unsigned int i = 0; i < pForegroundLayers->size(); i++)
            {
                (*pForegroundLayers)[i]->Draw(position, !isRightSide, 1.0);
            }
        }
    }
}
开发者ID:GabuEx,项目名称:my-little-investigations,代码行数:45,代码来源:DialogCharacterManager.cpp

示例15: DrawStrip

	void DrawStrip( float fRightEdgePercent )
	{
		RectI rect;

		const float fChamberWidthInPercent = 1.0f/NUM_CHAMBERS;
		const float fStripWidthInPercent = 1.0f/NUM_STRIPS;
		
		const float fCorrectedRightEdgePercent = fRightEdgePercent + fChamberWidthInPercent;
		const float fCorrectedStripWidthInPercent = fStripWidthInPercent + 2*fChamberWidthInPercent;
		const float fCorrectedLeftEdgePercent = fCorrectedRightEdgePercent - fCorrectedStripWidthInPercent;


		// set size of streams
		rect.left	= int(-METER_WIDTH/2 + METER_WIDTH*max(0,fCorrectedLeftEdgePercent));
		rect.top	= int(-METER_HEIGHT/2);
		rect.right	= int(-METER_WIDTH/2 + METER_WIDTH*min(1,fCorrectedRightEdgePercent));
		rect.bottom	= int(+METER_HEIGHT/2);

		ASSERT( rect.left <= METER_WIDTH/2  &&  rect.right <= METER_WIDTH/2 );  

		float fPercentCroppedFromLeft = max( 0, -fCorrectedLeftEdgePercent );
		float fPercentCroppedFromRight = max( 0, fCorrectedRightEdgePercent-1 );


		m_sprStreamNormal.StretchTo( rect );
		m_sprStreamHot.StretchTo( rect );


		// set custom texture coords
//		float fPrecentOffset = fRightEdgePercent;

		RectF frectCustomTexRect(
			fPercentCroppedFromLeft,
			0,
			1-fPercentCroppedFromRight,
			1);

		m_sprStreamNormal.SetCustomTextureRect( frectCustomTexRect );
		m_sprStreamHot.SetCustomTextureRect( frectCustomTexRect );

		m_sprStreamHot.SetDiffuse( RageColor(1,1,1,m_fHotAlpha) );

		m_sprStreamNormal.Draw();
		m_sprStreamHot.Draw();
	}
开发者ID:augustg,项目名称:stepmania-3.9,代码行数:45,代码来源:LifeMeterBar.cpp


注:本文中的Sprite::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。