适用于单个对象的Monogame XNA变换矩阵? [英] Monogame XNA transform matrix for a single object?

查看:66
本文介绍了适用于单个对象的Monogame XNA变换矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些教程,解释了XNA/Monogame的转换矩阵.问题在于这些矩阵被应用于

I have read a few tutorials explaining transform matrices for XNA/Monogame. The problem is that these matrices are applied to

SpriteBatch.Begin(...matrix);

这意味着所有绘图代码将被转换. 如何将变换矩阵应用于单个可绘制对象?在我的情况下,我想转换滚动背景,以使其自动换行.

This means that all Draw code will be transformed. How do I apply a transformation matrix to a single drawable object? In my case I want to transform a scrolling background so that it automatically wraps.

SpriteBatch.Draw(.. this has no transform matrix parameter?);

推荐答案

如果只想对某些图形调用使用特定的spritebatch开始调用,则可以根据需要开始一个新的调用.

If you want to use a specific spritebatch begin call for some drawing calls only, you can start a new one as needed.

例如

SpriteBatch.Begin(...matrix);

//Draw stuff with matrix

SpriteBatch.End();

SpriteBatch.Begin();

//do the rest of the drawing

SpriteBatch.End();

这通常用于在适当的位置,比例和旋转位置绘制一堆带有相机"矩阵的对象,然后绘制另一个spritebatch.开始调用是在顶部绘制平坦的静态UI,等等.

this is commonly used to draw a bunch of objects with a "camera" matrix at appropraite position, scale and rotation, then another spritebatch.Begin is called to draw the flat, static UI on top, etc.

这篇关于适用于单个对象的Monogame XNA变换矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆