PIXI.js - scrolling background grid

时间:2018-04-18 17:47:16

标签: javascript html graphics pixi.js pixijs

In the game agar.io, there is a grid background, and It scrolls with the player as they move. In PIXI.js, how would I go about recreating this? Preferably, in an efficient way that does not waste resources by rendering off-screen grid.

2 个答案:

答案 0 :(得分:1)

您应该使用PIXI.extras.TilingSprite类,它是为了渲染可重复的图案,图块等而创建的。该类仅对整个图案使用一个四边形(两个三角形),在片段着色器中实现重复。

以下是一个工作示例:http://pixijs.io/examples/#/basics/tiling-sprite.js

以下是文档:http://pixijs.download/release/docs/PIXI.extras.TilingSprite.html

答案 1 :(得分:-1)