QLNEO

Members
  • Content count

    38
  • Joined

  • Last visited

  1. From what it seems, z values (objects' drawing order on canvas) are intrinsically related to the groups each object is part of, and z values are only compared between same-level groups. Is there any way of making an object of group A to be rendered over an object of group B without having to set the entire group A to be rendered over group B?
  2. It wasn't, of course. I forgot to fix the name. Huge thanks!
  3. What I'm trying to do is to set an internal value to change via a tween invoked inside that same object. IDK if that's even legal but that's what I'm doing right now. class TheObject extends Phaser.Sprite { constructor() { ... this.circleAngle = 90; game.add.tween(this) .to({circleAngle: 360}, this.period*1000, null, true, 1000, -1) .onUpdateCallback(function(tween, value) { console.log(value); // NaN! }) } } The idea is to loop circleAngle continously, but all the tween's doing is NaNing it. Any ideas on how to make it really interpolate as I intended?
  4. Phaser and larger-scale games?

    First, thanks to you all for the insight. Now, for some observations: So, service workers would come to the rescue? Naturally. I'm not even thinking about doing something with that scope (or at least not with that level of graphical complexity), but thought that'd be a nice example, considering WebGL looks reasonably robust. Maybe I wouldn't do that, but I'd like to know how possible would it be for someone more prepared. What do you mean by console environments? You mean a dedicated engine or something like that? Based on all your comments, if I wanted to do a large scale game, I could take some options into consideration: If the game's too large for the player to download every time they access the page, either use NWjs to make it a native app or try some clever new thing with having the player load previously downloaded game files directly from their pc into the browser, if that's even possible; Service workers to simulate threading; A bunch of optimizations for nasty browser behavior; Waiting for Nidium to mature; If all else fails, give up on HTML5 for bigger games and try Löve2D or something instead. As Rich accurately stated, HTML5 is not really a platform geared towards serious gaming, so the last option seems the most viable, but it would be very sad to leave Javascript. I can learn another language if required, but I'd have to abandon the rapidly-growing Javascript ecosystem. I'm making a rhythm game of sorts, where MIDI files are converted to data to be used in the game; what if the engine I migrate to simply doesn't have something like this around? That's one of the reasons why I started this thread. To wrap it up: Following your insights, most browser constraints appear to concern the GPU. Will games that are not particularly graphic-intensive suffer? To be more practical: would a game like, say, Nuclear Throne work well if it was made in Phaser? It does have a ton of stuff happening on screen at once, but no fancy shaders and stuff. What about the likes of Dwarf Fortress? Nearly no graphics but a crapton of data. Or what about a SNES-styled JRPG? Not graphically intensive but games like that usually have around 20 hours worth of content.
  5. Phaser and larger-scale games?

    @bruno_I meant larger scale in respect to content (e.g. a full game, like a 20-hour JRPG for example) more than anything. I wonder what's the graphical limit of Phaser as well however, even though it's 2D-only - if I'm correct, Ori and the Blind Forest uses 2D graphics. I honestly can't imagine Phaser rendering something as graphical as Ori, but I don't think anyone even tried.
  6. Phaser and larger-scale games?

    This is a more open-ended question than the "how to do X" or "is there a feature X" that are frequently posted by me and pretty much everyone else around here. It's more like a discussion I want to make. I've read more than once that Phaser is not really ideal for "big" games, instead being for these smaller browser games we're all used to. And while I can see that, what are really the impediments for games of a larger scale? Is it the amount of data the user would have to download for every load (since it would be played on browser)? In that case, would a NWjs app do good no matter the size? Or is it that Phaser is not really optimized for games containing a lot of data and would lag/break on most machines? And what would be a scale too large for Phaser? Are we talking about indie large or AAA large? These are some of the questions I have when I'm confronted with Phaser's supposed scale limitations. While I don't have immediate plans to start a bigger project right now, I'd wish to know a bit more about this. EDIT FOR CLARIFICATION: When I say "large scale" I mean in terms of content. Not necessarily graphics or massive multiplayer characteristics, although these may be other factors of an ambitious project and are worth discussing.
  7. In-game randomization of tiles?

    My objective is to have two possible tiles (a normal and a "damaged" version of the same graphic) for a specific position, so that there's a chance, for each tile position, that what appears on the ingame tileset is the second version. What I wish, however, is to put that information in the tilemap if possible. If not possible, I'd want to know what are the other ways to do that. A randomly activated putTile() probably would be one of these, from what I gather.
  8. In-game randomization of tiles?

    So, I'm making a game with procedurally-generated rooms, and I want them to have similar walls, but some tiles replaced with "cracked" versions, to make things look more organic. For that effect, the ideal would be that each tile would have a chance to be replaced by the alternative. I'm aware that Tiled has options for randomizing tiles during tileset construction, but I would have to create a limited number of tilemaps for each variation, I'd rather have them be generated at runtime. What's the better way to go about this? One thing I have in mind is using putTile for every tile to be replaced, but that would be a bit cumbersome and I would have to deal with two sources of tilemap data, the tilemap and the randomizer. Still doable, but I'd rather have the information in the tilemap itself, if that's possible.
  9. Yeah, that was the ticket. Embarassingly enough, that even crossed my mind, but I was afraid that it would mess up with the onStop listener I set to the intro, but I knew I could just remove the listener before. By then that simple thought already went away and I tried going with removeAll() instead. Thanks again
  10. All I need is to stop all sound playback before I load another state. I have this music playing at the menu, and I'm having trouble when transitioning into the main game. It goes as follows: music intro and music loop are separated files; intro plays once, and its onStop event has a listener that plays the loop (on loop, of course). If I do nothing, when state changes, the playback won't stop (even though clearWorld parameter is true), and it'll attempt to loop as well. If I use game.sound.destroy() before starting the new state, "An attempt was made to use an object that is not, or is no longer, usable". Maybe it has to do with the fact that I'm using, as a placeholder, the menu music in the main game, but fact is, even if I load the audio file again in preload(), it just doesn't let me play and crashes. :/
  11. Failing miserably with alignTo()

    I don't like bumping threads, but... As much as I already got over this by setting the positions myself, I'd still like to know if I did something wrong or alignTo() is just this broken.
  12. I'm currently working with lots of groups, and I really miss a kill() for groups. Not killAll(), I mean kill(). Since groups have alive, exists and visible properties, and that applies to children, it would be just natural to be able to kill groups as well. Of course... I'm still a newbie with Phaser. I apologize if there's already something like it, but surfing the docs there appears to be nothing.
  13. Failing miserably with alignTo()

    Currently making a menu, I have a bunch of buttons, that are essentially groups containing the button sprite itself and text. Trying to vertically align each subsequent group with their previously added button sprite inside the group (since we can't directly alignTo() groups). The code is essentially how it reads below: let rect, buttons; let InitState = { preload: function() { let square = this.game.add.graphics(0,0); square.beginFill(0xFFFFFF,1); square.drawRect(0,0,200,100); rect = square.generateTexture(); square.clear(); }, create: function() { buttons = this.game.add.group(); buttons.position = {x: 50, y: 50} let btnarray = ["ONE","TWO","THREE","FOUR","FIVE"]; btnarray.forEach(function(btnTxt) { let buttonGroup = this.game.add.group(buttons); let image = rect; let buttonImg = buttonGroup.add(this.game.make.button(0,0,rect)); let txt = buttonGroup.add(this.game.make.text(buttonImg.width/2,buttonImg.height/2,btnTxt)) txt.anchor = {x: 0.5, y: 0.5}; if(buttons.children.length>1) { // We won't be needing to align the first one buttonGroup.alignTo( buttons.getAt(buttons.children.length-2).children[0], // buttonImg Phaser.BOTTOM_LEFT, 0, 4 ); } }.bind(this)) }, } let Game = new Phaser.Game( 800, 600, "", Phaser.AUTO, InitState ); This is a simplified version of what I'm doing, but even in this simplified version, the same thing occurs. The first and second buttons are correctly placed, but the third one is positioned in top of the second, and the fourth in top of the third. As you can see on the picture below, we can only see the first and last buttons, because the rest is buried under "five". alignTo() always refers to the second-to-last button in the group (the last being the one I'm trying to move), so why it seems to always take position (0,0) (relative to buttons) as reference? Thanks in advance.
  14. Thank you for your answers. @mattstyles my code looks more like this: function preload() {...} function create() { ... fun1.bind(this)() } function update() { ... fun2.bind(this)(); fun3.bind(this)() } // Yeah I could use call() instead, but I find this easier to understand the function parameters function fun1() {...} function fun2() {...} function fun3() {...} module.exports = { // Calling this file as state object later preload, create, update } In short, I want to use the state functions, and I also define some other functions they'll keep using throughout the state.
  15. Two threads in less than 30 minutes. I hope I'm not tiring you guys! This is more a Javascript-related question than anything. In short, I'm utilizing this.game in my state functions. However, when invoking functions inside these functions, their scope isn't the Phaser state anymore, so this becomes undefined. Sure enough, I can simply use functionName.bind(this)(parameters), or functionName.call(this, parameters), and that's what I'm doing right now, but when I do that for every function internally called, it starts becoming an anti-pattern, doesn't it? Anyone has an idea on how can I make sure this refers to Phaser state without having to assign bind() to every function my state funcions call? Thanks!