• Content Count

  • Joined

  • Last visited

  1. Thanks Drhayes. Still new to Phaser so this one tripped me up.
  2. It's been a long day and I might just be overlooking the basics, but this seems wrong to me for some reason. var MyClass = function() {var self = this;this.game = new Phaser.Game(1024, 768, Phaser.AUTO, 'game', {preload:this.preload});}MyClass.prototype.constructor = MyClass;MyClass.prototype.preload = function() {console.log(this); // <--- Phaser.Game, not MyClass}var app = new MyClass();
  3. I'm talking the user defined callbacks.
  4. Why do you do this in Phaser? For example, the preload/create callbacks, changes the context by using call and sets it to the game. That just stomps on prototypal class structure, if for example, you wanted a class to contain a game object. Should it behave this way? Why not just pass a reference to the game as an argument, or allow the end user to handle it themselves and not force this?
  5. Took me a while to followup. For those interested, drhayes was correct. You simply extend Phaser.Particle and there is an onEmit callback that the emitter invokes at creation. Here's some sample code: var confetti_colors = ['FFFF00','FF9933','FF0000','3399FF','9933CC'];var ConfettiParticle = function(game, x, y, key, frame){ Phaser.Particle.call(this, game, x, y, key, frame);}ConfettiParticle.prototype = Object.create(Phaser.Particle.prototype);ConfettiParticle.prototype.constructor = ConfettiParticle;ConfettiParticle.prototype.onEmit = function(){ this.tint = '0x'+confetti_colors[Math.floor(Math.random()*confetti_colors.length)];}... (where you define your emitter) ...emitter.particleClass = ConfettiParticle;
  6. Is it possible to get an oncreate callback or some such for the particle emitter? I just want to randomly set the particle color when it's created (via tint, for example). Right now, I have to make a function on update that steps through non-colorized particles and sets a color (then a flag so I don't re-set the color again). This works, but it's not terribly efficient, FPS wise. Any other way to accomplish this?
  7. Always feel silly asking then answering it myself, but for those interested you can accomplish this by making your own bitmap data object, filling the text (plain ol' canvas method, ctx.fillText for example) and then use the bitmap data itself to construct your phaser sprite. For example: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'render-text', { preload: preload, create: create });var bmd = null;var spr = null;// The Google WebFont Loader will look for this object, so create it before loading the script.WebFontConfig = { active: function() { game.time.events.add(Phaser.Timer.SECOND, createText, this); }, google: { families: ['Revalia'] }};function preload() { game.load.script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js');}function create() { game.stage.setBackgroundColor(0x2d2d2d); bmd = game.make.bitmapData(400,200);}function createText() { bmd.ctx.beginPath(); bmd.ctx.rect(0,0,400,200); bmd.ctx.fillStyle = '#FF0000'; bmd.ctx.fill(); bmd.ctx.fillStyle = '#000000'; bmd.ctx.font = '32px Revalia'; bmd.ctx.fillText('hello,phaser!',40,40); spr = game.add.sprite(100,100,bmd); spr.inputEnabled = true; spr.input.enableDrag();}
  8. So I'm basically trying to make a tilesprite composed of text. The idea is so I can have dynamic text to behave like a sprite, rather than constructing a different spritesheet for every kind of font I might need. The primary use is to scroll through the text (think like a slot machine?) composed of text, rather than icons. Hence the tilesprite, but I'm sure there's other ways to do it. None of the examples really deal with text being used in such a fashion, so I'm not sure where to begin. This is done fairly simply in just plain old canvas, but I'm not really sure a Phaser equivalent? I thought perhaps RenderTexture, but I can't seem to construct one without using an actual image. I haven't used Phaser since 1.1.3 or so, so I'm not really familiar with all the changes. Anyone got some insight on where to begin here?
  9. Anyone done it yet? http://www.brashmonkey.com/spriter.htm
  10. --edit, missed a part of what you said about the pot being limited to tiled sprites. Thanks for your help on this stuff, I'll hack away and see what's what. I'll likely just stick to Canvas though, it's not a terribly performance hungry application.
  11. Hi all. Enjoying Phaser thus far, but one primary concern I have is if the window running phaser is not in focus, phaser simply stops executing. I know javascript doesn't halt on my system when out of focus, and I've seen other HTML5 games continue to animate (albeit at lower interval of course), but Phaser just outright stops. Is this by design or a limitation? Is there an obvious work around I am not seeing in the docs? Secondly, about WebGL. 1) Is power of 2 always going to be a constraint? I know at the hardware level it is, but many libraries have overcome the issue for end-developers... This of course is not a high priority thing, but I'm just curious (for now I just use canvas). 2) Using a tiled sprite, there is a great degree of shaking/blinking making it pretty much unusable for my current implementation. I read (and posted to no avail) in a previous thread who said upgrading to 1.1.3 fixed the issue for him (he was talking about the examples). For me, though, even with the latest branch it still does it when webGL is selected. I'm on MacOS using Chrome, but the behavior is reproduced for me across every browser so far (I have VM access and can try it on any OS ever; but immediately it annoys me greatly and so I just use canvas for now I'd like to use AUTO for the game object, however, for obvious reasons. Though the power of 2 issue pretty much kills it for my game due to the way my project is designed. I'm making a slot machine game and the "reels" scroll based on a fixed image and so the texture must be 1 icon in width and X icons in height -- and power of 2 crushes my hopes and dreams for variable reel lengths. (Perhaps I'm lazy and shouldn't tile sprite and generate random sprites for the rolling animation; trying to be efficient here tho and maintain some realistic feel -Dan
  12. This is interesting, I just converted my project over to use a tiling sprite, and in WebGL the shaking is really bad, but not in Canvas mode. I'm using 1.1.3 and this is happening. The positions are not floats, it happens before any movement even happens. I'll use canvas mode for the time being but I'd be interesting in seeing what's causing it in GL.
  13. Oh nice, I'll check that out. Yeah I had to make duplicate icons on the image in order to achieve the wrapping effect, so maybe this will be an even more ideal solution. I'll give it a look and see what's what! Not to derail this, but since topics take a while to post and it's semi related -- I come from C++ (and even python) game programming, and generally you have to explicitly render/draw your objects. How come in Phaser all this is handled automatically? I mean even using the graphics object I don't have to redraw it every frame. Heck I don't even have a draw/render function implemented! Kinda strange, but kinda convenient all the same -- but I guess I feel kind of naked not knowing exactly how it's happening
  14. Yep, I am cropping. I was making a slot machine with 3 "reels" you know. It works pretty well to just scroll through the image using crop. Performance-wise, it might be superior to break it up and not "scroll" the main image. Considering this, seems like that's the way I'll have to go. I didn't want to get head long into converting to that methodology only to run into this issue. So long as I don't crop I am good then, hm? Thanks.