/** Called by game loop, updates then blits or renders current frame of animation to the screen */ @Override public void draw() { if (_flicker) return; if (dirty) // rarely calcFrame(); if (_newTextureData != null) // even more rarely { _pixels.getTexture().load(_newTextureData); _newTextureData = null; } FlxCamera camera = FlxG._activeCamera; if (cameras == null) cameras = FlxG.cameras; if (!cameras.contains(camera, true)) return; if (!onScreen(camera)) return; _point.x = x - (camera.scroll.x * scrollFactor.x) - offset.x; _point.y = y - (camera.scroll.y * scrollFactor.y) - offset.y; _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f; _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f; // tinting int tintColor = FlxU.multiplyColors(_color, camera.getColor()); framePixels.setColor( ((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, _alpha); // rotate if (_pixels.rotate) framePixels.rotate90(false); if (isSimpleRender()) { // Simple render framePixels.setPosition(_point.x, _point.y); renderSprite(); } else { // Advanced render framePixels.setOrigin(origin.x, origin.y); framePixels.setScale(scale.x, scale.y); if ((angle != 0) && (_bakedRotation <= 0)) framePixels.setRotation(angle); framePixels.setPosition(_point.x, _point.y); if (blend != null && currentBlend != blend) { currentBlend = blend; int[] blendFunc = BlendMode.getOpenGLBlendMode(blend); FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]); } else if (FlxG.batchShader == null || ignoreBatchShader) { // OpenGL ES 2.0 shader render renderShader(); // OpenGL ES 2.0 blend mode render renderBlend(); } renderSprite(); } // re-rotate if (_pixels.rotate) framePixels.rotate90(true); _VISIBLECOUNT++; if (FlxG.visualDebug && !ignoreDrawDebug) drawDebug(camera); }
@Override public void draw() { if (_flickerTimer != 0) { _flicker = !_flicker; if (_flicker) return; } FlxCamera camera = FlxG._activeCamera; if (cameras == null) cameras = FlxG.cameras; if (!cameras.contains(camera, true)) return; if (!onScreen(camera)) return; _point.x = x - (camera.scroll.x * scrollFactor.x) - offset.x; _point.y = y - (camera.scroll.y * scrollFactor.y) - offset.y; _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f; _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f; // scaling BitmapFont font = _textField.getFont(); if (scale.x != font.getScaleX() || scale.y != font.getScaleY()) { _textField.getFont().setScale(scale.x, scale.y); calcFrame(); } // position _textField.setPosition(_point.x, _point.y); // rotation if (angle != 0) { _matrix = FlxG.batch.getTransformMatrix().cpy(); Matrix4 rotationMatrix = FlxG.batch.getTransformMatrix(); rotationMatrix.translate( _textField.getX() + (width / 2), _textField.getY() + (height / 2), 0); rotationMatrix.rotate(0, 0, 1, angle); rotationMatrix.translate( -(_textField.getX() + (width / 2)), -(_textField.getY() + (height / 2)), 0); FlxG.batch.setTransformMatrix(rotationMatrix); } // blending if (blend != null && currentBlend != blend) { int[] blendFunc = BlendMode.getOpenGLBlendMode(blend); FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]); } else if (Gdx.graphics.isGL20Available() && (FlxG.batchShader == null || ignoreBatchShader)) { // OpenGL ES 2.0 shader render renderShader(); // OpenGL ES 2.0 blend mode render renderBlend(); } // Render shadow behind the text if (_shadow != 0) { // tinting int tintColor = FlxU.multiplyColors(_shadow, camera.getColor()); _textField.setColor( ((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, ((_shadow >> 24) & 0xFF) * _alpha * 0.00392f); _textField.translate(_shadowX, _shadowY); _textField.draw(FlxG.batch); _textField.translate(-_shadowX, -_shadowY); } // tinting int tintColor = FlxU.multiplyColors(_color, camera.getColor()); _textField.setColor( ((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, _alpha); _textField.draw(FlxG.batch); // rotation if (angle != 0) FlxG.batch.setTransformMatrix(_matrix); _VISIBLECOUNT++; if (FlxG.visualDebug && !ignoreDrawDebug) drawDebug(camera); }