mirror of
https://github.com/wassname/phaser.git
synced 2026-08-03 13:10:25 +08:00
Game.add.renderTexture now has the addToCache parameter. If set the texture will be stored in Game.Cache and can be retrieved with Cache.getTexture(key).
Game.add.bitmapData now has the addToCache parameter. If set the texture will be stored in Game.Cache and can be retrieved with Cache.getBitmapData(key).
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
@@ -13,17 +13,14 @@ var image;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll create a renderTexture the same size as our game
|
||||
texture = game.add.renderTexture('mousetrail', 800, 600);
|
||||
|
||||
// This is the sprite that will be drawn to the texture, we set it to visible false as we only need its texture data
|
||||
mushroom = game.add.sprite(0, 0, 'mushroom');
|
||||
// mushroom.visible = false;
|
||||
// mushroom.anchor.setTo(0.5, 0.5);
|
||||
// We create a sprite (rather than using the factory) so it doesn't get added to the display, as we only need its texture data.
|
||||
mushroom = new Phaser.Sprite(game, 0, 0, 'mushroom');
|
||||
mushroom.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// This is the sprite that is drawn to the display. We've given it the renderTexture as its texture.
|
||||
// game.add.image(0, 0, texture);
|
||||
|
||||
image = game.add.image(0, 0, texture);
|
||||
|
||||
game.input.onDown.add(tint, this);
|
||||
|
||||
@@ -41,14 +38,11 @@ function update() {
|
||||
{
|
||||
// Here we draw the mushroom sprite to the renderTexture at the pointer coordinates.
|
||||
// The 'false' parameter 2nd from the end tells it not to clear itself, causing the trail effect you see.
|
||||
// The final 'true' parameter tells it to render sprites even with visible false set.
|
||||
// texture.render(mushroom, game.input.activePointer.position, false, true);
|
||||
texture.render(mushroom, game.input.activePointer.position, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderText(game.input.x, 32, 32);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user