में खींचने के बिना पूर्णस्क्रीन जा रहा है मेरे पास एक 2 डी गेम है जिसे मैं 4: 3 पहलू अनुपात में काम कर रहा हूं। जब मैं इसे अपने वाइडस्क्रीन मॉनीटर पर पूर्णस्क्रीन मोड में स्विच करता हूं तो यह फैलता है। मैंने दो व्यूपोर्ट्स का उपयोग करके काले रंग की पृष्ठभूमि देने के लिए कोशिश की जहां खेल को खिंचाव नहीं किया जाना चाहिए, लेकिन इस खेल को पहले के आकार में छोड़ दिया गया था। मैं उस व्यूपोर्ट को भरने के लिए नहीं मिला जो पूरे गेम को पकड़ना था।एक एक्सएनए गेम
मैं इसे बिना खिंचाव के पूर्णस्क्रीन जाने के लिए कैसे प्राप्त कर सकता हूं और मुझे बिना किसी स्थिति को संशोधित करने और गेम में कथन बनाने की आवश्यकता क्यों है? कोड जो मैं व्यूपोर्ट्स के लिए उपयोग कर रहा हूं वह नीचे है।
// set the viewport to the whole screen
GraphicsDevice.Viewport = new Viewport
{
X = 0,
Y = 0,
Width = GraphicsDevice.PresentationParameters.BackBufferWidth,
Height = GraphicsDevice.PresentationParameters.BackBufferHeight,
MinDepth = 0,
MaxDepth = 1
};
// clear whole screen to black
GraphicsDevice.Clear(Color.Black);
// figure out the largest area that fits in this resolution at the desired aspect ratio
int width = GraphicsDevice.PresentationParameters.BackBufferWidth;
int height = (int)(width/targetAspectRatio + .5f);
if (height > GraphicsDevice.PresentationParameters.BackBufferHeight)
{
height = GraphicsDevice.PresentationParameters.BackBufferHeight;
width = (int)(height * targetAspectRatio + .5f);
}
//Console.WriteLine("Back: Width: {0}, Height: {0}", GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
//Console.WriteLine("Front: Width: {0}, Height: {1}", width, height);
// set up the new viewport centered in the backbuffer
GraphicsDevice.Viewport = new Viewport
{
X = GraphicsDevice.PresentationParameters.BackBufferWidth/2 - width/2,
Y = GraphicsDevice.PresentationParameters.BackBufferHeight/2 - height/2,
Width = width,
Height = height,
MinDepth = 0,
MaxDepth = 1
};
GraphicsDevice.Clear(Color.CornflowerBlue);
नीचे दी गई छवि से पता चलता है कि स्क्रीन कैसी दिखती है। किनारों पर काली वह है जो मैं चाहता हूं (और पहले व्यूपोर्ट से है) और दूसरा व्यूपोर्ट गेम और कॉर्नफ्लॉवर ब्लू एरिया है। मैं चाहता हूं कि कॉर्नफ्लॉवर नीले क्षेत्र को भरने के लिए गेम को स्केल करना है। 3 पहलू और 16: 9 पहलू
आपको यह जानने में रुचि हो सकती है कि वास्तव में गेम डेवलपमेंट स्टैक एक्सचेंज साइट है, जहां आपको इसके लिए बेहतर जवाब मिल सकता है: http://gamedev.stackexchange.com/ –