Search the Community
Showing results for tags 'reference'.
-
A 3d reference grid using BABYLON.MeshBuilder.CreateLineSystem http://www.babylonjs-playground.com/#P6XHUB
-
Hi! I am trying to do a new plugin but I don't know why this piece of code doesn't work. I reduced my real code to a basic case,so it will be easy to understand. I have a problem with the functions setTexture and setColor. Although I pass as a parameter the object that I want to modify, when the function returns the object is inmutable, the state is the same that it was before calling the function. For example "this.bitmap" is an empty object after call "setTexture()", but I worked over him inside the function. Someone can help me with this? I think maybe it will be a scope problem but I can't find an explanation. You can see the working code in the following fiddle: https://jsfiddle.net/p78bzn9w/5/ . In the console you can also view the behaviour of the values that I described or you can see the code here: Phaser.Plugin.Virtual = function(game, parent) { Phaser.Plugin.call(this, game, parent); this.game = game; }; Phaser.Plugin.Virtual.prototype = Object.create(Phaser.Plugin.prototype); Phaser.Plugin.Virtual.prototype.constructor = Phaser.Plugin.Virtual; Phaser.Plugin.Virtual.prototype.setup = function (player, buttons){ this.bitmap = {}; //here this.bitmap is {}, I pass as the first parameter this.setTexture(this.bitmap, '#4BAFE3', 30, 30); //after return setTexture, this.bitmap is {} again but it would be a bitmap this.arrow = {}; //here this.arrow is {}, I pass as the first parameter too this.setColor(this.arrow, 10, 20, this.bitmap , 0.5, 90); //the same problem as before, this.arrow is {} but it would be a button } Phaser.Plugin.Virtual.prototype.setTexture = function (item, color, width, height){ //I create a bitmap in item //item is this.bitmap var item = this.game.add.bitmapData(width, height); item.ctx.fillStyle = color; item.ctx.fillRect(0,0,width, height); //here item is a bitmap }; Phaser.Plugin.Virtual.prototype.setColor = function (item, x, y, bitmap, alpha){ //I create a button in item //item is "this.arrow". item = this.game.add.button( x, y, bitmap); item.alpha = alpha; item.fixedToCamera = true; //here item is a button }; Thanks so much!
-
- parameters
- reference
-
(and 3 more)
Tagged with:
-
Hello guys, I'm having a bit of trouble applying what I read from the documentation. For instance, I want to use the input keyboard properties of "lastChar" and "lastKey", but I just don't know how to translate that into code. This is what i have tried: this.game.input.keyboard.lastChar; this.game.input.keyboard.lastKey; this.game.input.keyboard.lastKey(); I tried other combinations that didn't work. Do any of you guys know how to apply the code from the docs that are not seen in any of the examples? Thanks guys!
- 6 replies
-
- Documentation
- code
-
(and 1 more)
Tagged with:
-
Hey all, I'm making a single page app that uses a Pixi CanvasRenderer on one of the screens. When I clean up my views in JS, I am getting zombie objects because there's no way to unbind the events on the Pixi renderer/stage. Take a look at this heap snapshot... How can I free up these objects for collection? Thanks a lot!
-
Hi, I've run into some trouble while trying to align some animations of a character. I made the character in Adobe flash CS6 and used its new tool to generate a spritesheet + atlas json file of several animations of the same character (walk, attack, idle, etc). Each animation is correctly animated and displayed individually, however, when I switch in-between them, I find they are not aligned, that is, there is no common reference point between the animations, so when I switch from, let's say, idle to attack, the character seems to "move" to another position. I managed to modify the plugin used by adobe flash to generate the spritesheet, so that it includes the registration Point of each individual animation (of each movie clip), so I currently have that information in my json file. I guess that is a good actual reference point between the animations (correct me if I'm wrong), I located it at the 'feet' of my character in each movie clip. So now, having that data, what is the most efficient way to use it with Phaser to solve this problem. Do I have to offset the position manually every time I switch the animation? is there no better way? is this a common problem, or am I doing something wrong from the beginning? Any help would be greatly appreciated
- 18 replies
-
- registration Point
- origin
-
(and 3 more)
Tagged with: