mirror of
https://github.com/wassname/phaser.git
synced 2026-07-14 01:10:16 +08:00
Finished off RenderTexture. Sprites can now accept a RenderTexture or a key when you create them. RenderTextures are also now stored in the cache under their own key, making re-using them across other Sprites much easier. Also ported over all of the Tilemap classes, but need to get them rendering.
This commit is contained in:
@@ -21,13 +21,13 @@ Phaser.GameObjectFactory.prototype = {
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite
|
||||
* @param [texture] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture
|
||||
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
sprite: function (x, y, key, frame) {
|
||||
sprite: function (x, y, texture, frame) {
|
||||
|
||||
return this.world.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
return this.world.add(new Phaser.Sprite(this.game, x, y, texture, frame));
|
||||
|
||||
},
|
||||
|
||||
@@ -36,13 +36,13 @@ Phaser.GameObjectFactory.prototype = {
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this sprite
|
||||
* @param [texture] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture
|
||||
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
child: function (parent, x, y, key, frame) {
|
||||
child: function (parent, x, y, texture, frame) {
|
||||
|
||||
var child = this.world.add(new Phaser.Sprite(this.game, x, y, key, frame));
|
||||
var child = this.world.add(new Phaser.Sprite(this.game, x, y, texture, frame));
|
||||
parent.addChild(child);
|
||||
return child;
|
||||
|
||||
@@ -52,12 +52,11 @@ Phaser.GameObjectFactory.prototype = {
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @param obj {object} Object the tween will be run on.
|
||||
* @param [localReference] {bool} If true the tween will be stored in the object.tween property so long as it exists. If already set it'll be over-written.
|
||||
* @return {Phaser.Tween} The newly created tween object.
|
||||
*/
|
||||
tween: function (obj, localReference) {
|
||||
tween: function (obj) {
|
||||
|
||||
return this.game.tweens.create(obj, localReference);
|
||||
return this.game.tweens.create(obj);
|
||||
|
||||
},
|
||||
|
||||
@@ -109,4 +108,14 @@ Phaser.GameObjectFactory.prototype = {
|
||||
|
||||
},
|
||||
|
||||
renderTexture: function (key, width, height) {
|
||||
|
||||
var texture = new Phaser.RenderTexture(this.game, key, width, height);
|
||||
|
||||
this.game.cache.addRenderTexture(key, texture);
|
||||
|
||||
return texture;
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user