绘图方法将绘制图形设备上使用 Microsoft.Xna.Framewok.Graphics 命名空间中的 SpriteBatch 类。一组sprites被绘制的时候使用同样的设置。 spriteBatch = ScreenManager.SpriteBatch; // Make the menu slide into place during transitions, using float transitionOffset = (float)Math.Pow(TransitionPosition, 2); spriteBatch.Begin(); // Draw Background spriteBatch.Draw(background, new Vector2(0, 0), new Color(255, 255, 255, TransitionAlpha )); spriteBatch.End(); } 4.
操作界面 BitmapFont 1.定义:通过读取两个文件,一个是图片TextureRegion 另外一个是描述了每个字符位置,以及相关信息的配置文件,他们都是使用SpriteBatch绘制的。 3.绘制多行:drawMultiLine (SpriteBatch spriteBatch, CharSequence str, float x, float y, float alignmentWidth private val font by lazy { BitmapFont(Gdx.files.internal("hello.fnt")) } private val batch by lazy { SpriteBatch
spriteBatch; //声明一个精灵集群.可以以相同的设置操纵(draw)一组精灵//define a SpriteBatch Model myModel; //定义一个Model//define { e.GraphicsDeviceInformation.PresentationParameters.DeviceWindowHandle = mainform.Panel.Handle; } SpriteBatch (graphics.GraphicsDevice); base.Initialize(); } protected override void LoadContent() { //spriteBatch = new SpriteBatch(GraphicsDevice); //myModel = Content.Load<Model>("Models\\"+mainform.filename); // = new SpriteBatch(GraphicsDevice); myModel = Content.Load<Model>("Models\\" + mainform.filename); //
(SpriteBlendMode.None); Viewport viewport = GraphicsDevice.Viewport; spriteBatch.Draw(background, new Rectangle(0, 0, viewport.Width, viewport.Height), Color.White); spriteBatch.End(); // XNA 4.0 // 画背景图 spriteBatch.Begin(0, BlendState.Opaque); spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds (), Vector2.Zero, Color.White); spriteBatch.End(); postprocessEffect.CurrentTechnique.Passes[0 spriteBatch.Begin(0, BlendState.Opaque, null, null, null, postprocessEffect); spriteBatch.Draw(sceneRenderTarget
以及封装了一个精灵类(SpriteBatch) 特点: 1.Stage可以铺满屏幕,设置视角大小,同时设置照相机 2.调配Actor,Group 与 Screen之间的关系转换,一个Stage必须负责接收输入事件 Gdx.input.inputProcessor = stage 来实现监听注册 舞台类以及使用 public Stage (float width, float height, boolean keepAspectRatio, SpriteBatch 比如:Routation 3.public void draw (SpriteBatch batch, float parentAlpha) 演员(Actor)本身也可以在舞台中绘制自己。
resources 目录,Android项目对应assets 文件夹 3.Gdx.files.external("") 从外部存储获取 4.Gdx.files.absolute("") 绝对路径 ---- SpriteBatch ---- 画出图片: private val texture = Texture(Gdx.files.internal("aiweier.jpg")) private val batch = SpriteBatch 截取512*512 ---- Sprite类 1.定义:持有几何形状,颜色,和纹理信息使用加载绘制2D精灵 2.用途:TextureRegion的加强版,SpriteBatch的加强版,比TextureRegion sprite.setRotation(50) 4.绘制位置:sprite.setPosition(150,150) 5.绘制颜色:sprite.setColor(1,0,1,1) 6.绘制函数:sprite.draw(SpriteBatch
、在LoadContent中加载并开始播放视频: video = Content.Load
所以许多相同纹理可以一起描述并一起送入GPU,这就是libgdx SpriteBatch类所要做的。 SpriteBatch被赋予了纹理和坐标以便每个图形的绘制,它汇集了很多图形而没有直接提交给GPU。如果它被赋予的纹理不同于原有的,它将保持原有的图形,并获取新的图形。 initialize(new MyGame(), false); } } MyGame public class MyGame implements ApplicationListener { private SpriteBatch batch; // 批量绘制 private Texture texture; // 纹理 @Override public void create() { batch = new SpriteBatch
比如:Routation 3.draw(SpriteBatch batch,float parentAlpha) ,演员本身可以在舞台中绘制自己。
libgdx 父类接口 ApplicationListener , 详细定义如下: public class MyGame implements ApplicationListener { private SpriteBatch 初始化游戏精灵 private BitmapFont bf; // 初始化字体绘制 @Override public void create() { // 创建 batch = new SpriteBatch
deadzoneRadius, Skin skin) 第一个参数:设置摇杆触碰区域的半径大小 第二个参数:传入Skin类中的TouchPadStyle类型、 功能方法: public void draw (SpriteBatch
Group,一个可拖拽的对话框,顶部可以设置弹出框的标题 功能用法:主需要传入两个参数 Window (String title, WindowStyle style) 常用方法: 1.draw (SpriteBatch