我有一个问题,我的菜单和面板的菜单项被裁剪,所以这些东西不会低于面板的顶部。一切正常,你只是看不到那个点以下的东西。当我使用此代码检查该面板的位置时
if (Position.X <= 400)
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(700, 200), Item1, Item2, Item3, Item4);
else
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(100, 200), Item1, Item2, Item3, Item4);
前 4 个裁剪整个菜单,然后接下来的 8 个裁剪除一个部分以外的所有内容,依此类推。如果我不检查它(我只使用第 2 行),那么前 8 个会切断所有内容,接下来的 8 个会切断除一个部分之外的所有内容,依此类推。(旁注:每个部分的高度为 100 像素。)
这是用于初始化每个面板以及菜单和菜单项的代码:
for (int i = 0; i <= 7; i++)
{
for (int q = 0; q <= 7; q++)
{
Panel Panel = new Panel();
Panel.Initialize(TestTextureStill, TestTextureHover, TestTextureActive, new Vector2 (q * 100 + 50, i * 100 + 50), MenuTexture, menuItem1, menuItem2, menuItem3, menuItem4);
Panels[i, q] = Panel;
}
}
面板菜单
if (Position.X <= 400)
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(700, 200), Item1, Item2, Item3, Item4);
else
panelMenu.Initialize(TestPanelMenuTexture, new Vector2(100, 200), Item1, Item2, Item3, Item4);
下面是绘图代码:
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
for (int i = 0; i <= 7; i++)
{
for (int q = 0; q <= 7; q++)
Panels[i, q].Draw(spriteBatch);
}
spriteBatch.End();
base.Draw(gameTime);
Panel.Draw() 内部
if (selected)
panelMenu.Draw(spriteBatch);
spriteBatch.Draw(PanelTextureCurrent, Position, null, Color.White, 0f, new Vector2(Width / 2, Height / 2), 1f, SpriteEffects.None, 0f);
PanelMenu.Draw() 内部
spriteBatch.Draw(PanelMenuTexture, Position, null, Color.White, 0f, new Vector2(Width / 2, Height / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item1.CurrentTexture, new Vector2(Position.X, 50), null, Color.White, 0f, new Vector2(WidthMI1 / 2, HeightMI1 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item2.CurrentTexture, new Vector2(Position.X, 150), null, Color.White, 0f, new Vector2(WidthMI2 / 2, HeightMI2 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item3.CurrentTexture, new Vector2(Position.X, 250), null, Color.White, 0f, new Vector2(WidthMI3 / 2, HeightMI3 / 2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(Item4.CurrentTexture, new Vector2(Position.X, 350), null, Color.White, 0f, new Vector2(WidthMI4 / 2, HeightMI4 / 2), 1f, SpriteEffects.None, 0f);
如果您还需要什么,请告诉我!