1

I'm trying to render my 2D sprite sheet into a WebGL mesh.

Currently I have it setup like this:

var char = game.addChild();
char.setSizeMode('absolute', 'absolute')
    .setAbsoluteSize(x, y)
    .setPosition(0,0,0)
    .setAlign(0,1);

var charMesh = new Mesh(char);
var plane = new Plane();
charMesh.setGeometry(plane);

var image = Material.Texture('./assets/sprite.png');
charMesh.setBaseColor(image);

And what happens is I get a WebGL object with my entire sprite sheet as the background. I need a way to grab just a piece of the sheet, preferably by coordinates. Then I can swap out the coordinates to grab the next frame inside the sprite sheet. I believe this should be possible in some manner, and am reading through WebGL/OpenGL documents, but it's not very clear how it translates to Famo.us. Can anyone help out?

RenaissanceProgrammer
  • 404
  • 1
  • 11
  • 30

0 Answers0