none
UI with DirectXTK

    Question

  • Im setting up text and a heathbar with DirectXTK 11 using this code

    // Renders the current frame according to the current application state.
    // Returns true if the frame was rendered and is ready to be displayed.
    bool BeatdownMain::Render()
    {
    	// Don't try to render anything before the first Update.
    	if (m_timer.GetFrameCount() == 0)
    	{
    		return false;
    	}
    
    	auto context = m_deviceResources->GetD3DDeviceContext();
    
    	// Reset the viewport to target the whole screen.
    	auto viewport = m_deviceResources->GetScreenViewport();
    	context->RSSetViewports(1, &viewport);
    
    	m_sprites->Begin();
    	const wchar_t* output = "Boxer  + m_hostBoxer->Position;
    	Vector2 origin = m_font->MeasureString(output) / 2.f;
    	m_font->DrawString(m_sprites.get(), output, m_fontPos, Colors::White, 0.f, origin);
    	m_sprites->End();
    
    	m_sprites->Begin();
    	//Draw the negative space for the health bar
    	m_sprites->Draw(healthbar, new Rectangle(m_texture.Get(), 2 - m_screenPos.x / 2, 30, m_screenPos.x, 44), new Rectangle(0, 45, m_screenPos.x, 44), Colors::Gray);
    
    	//Draw the current health level based on the current Health
    	m_sprites->Draw(healthbar, new Rectangle(m_texture.Get(), 2 - m_screenPos.x / 2, 30, (int)(m_screenPos.x * ((double)mCurrentHealth / 100)), 44), new Rectangle(0, 45, m_screenPos.x, 44), Colors::Red);
    
    	//Draw the box around the health bar
    	m_sprites->Draw(healthbar, new Rectangle(m_texture.Get(), 2 - m_screenPos.x / 2, 30, m_screenPos.x, 44), new Rectangle(0, 0, m_screenPos.x, 44), Colors::White);
    	m_sprites->End();
    
    	// Render the scene objects.
    	// TODO: Replace this with your app's content rendering functions.
    	auto context = m_deviceResources->GetD3DDeviceContext();
    	m_Arena->Render();
    	m_hostBoxer->Render();
    
    
    	return true;
    }



    I keep getting errors about the rectangles, is there any way I can bring up rectangles using DirectXTK?




    Friday, February 09, 2018 8:33 PM