• Content Count

  • Joined

  • Last visited

About Tumetsu

  • Rank

Contact Methods

  • Twitter
  1. Alright, I think I tried something like that but didn't figure to modify my existing textures' baseTextures. Thanks. Btw, is the TextureCache in PIXI in state of flux atm? I keep finding mentions that it should be in utils, but on Pixi4 rc I found it from TextureManager which I couldn't find from docs.
  2. I'm building my first Pixi game and working on basic services for asset management. My game should support few different resolution asset packs. Pixi handles this fine with resolution values and scaling. Next part I'm working on is to reload higher definition assets when required. Lets say that player starts game on 800x500 embedded window but presses full screen toggle. In this case I'd like to load HD assets on background and then replace the SD assets with newer ones once loading is ready. Before implementation I'd like to know if there is any existing mechanism in Pixi for this kind of operation? Or if not, should I know something specific about Pixi's texture handling to avoid some pitfalls? My current idea is as follows: When user moves to HD mode, trigger reloadAssets event, which kicks of my AssetLoader which loads the set of resources I require at the moment. Loader stores the names and textures to a map in AssetStorage -service. Once this is finished, an updateAssets event is broadcasted. Each Sprite can listen this event and they will update their texture from my AssetStorage -service. The reason I'm slightly insecure about my design is because I don't know exact inner workings of Pixi's resource management. For example does Pixi clear assets automatically, which might mess up my AssetStorage -service? What exactly I need to do when I reload new versions of assets especially regarding the old assets?BaseTexture seems to have update() function, can I sue it for this case? I'm reading about this stuff but decided to drop a question here since these are things I couldn't yet find any clear examples. Also, I'm afraid I'll implement something which is already done better in Pixi
  3. Very good I wasn't really looking forward to implement that stuff myself. Choosing the right assets shouldn't be any problem so everything sounds good to me! I'm using Pixi v3. I now checked releases and Pixi v4 is in rc so I guess I should upgrade now rather than later.
  4. I intend to build my next point & click game with Pixi.js and I'm currently exploring its api and capabilities. In my game engine, I'd like to support multiple resolutions so that game would look nice on desktop and mobile. For this purpose I'd need a system which would scale the game properly depending on the device or canvas size on web page. To implement this I'd need basically two systems: 1) Coordinate transformation so that I could develop game in lets say 1920x1080 resolution and set object/sprites positions in that scake and then down or up scale the stage when needed to 800x450 for example. The first way I figured to do this would be to add some kind of transform into render which changes render coordinates of objects by some factor. Or I could just scale the whole stage at the beginning of the game to correct factor. 2) Small resolutions don't need high resolution assets while high def screens need larger resolution assets so I'd like to have simple asset packs for different resolutions. For example 800x450, 1920x1080 and retina resolutions would use different asset packs and game would load only relevant pack when the resolution of the game view is known. Now, I have an idea how to implement this stuff myself but what I'm wondering is if there is any premade functionality in Pixi for these tasks. When googling around I found this thread discussing about @2x suffixes for assets and how they set the resolution for each texture: The thread also links to this old blog post: http://www.goodboydigital.com/pixi-js-v2-fastest-2d-webgl-renderer/ which talks about how one could load a different asset for retina screens. These resources led me to think that there might be a simple way to implement proper scaling without worrying about coordinates and individual scaling of stuff and loading proper asset packs. So my question in the end is what is the easiest way to implement 1 and 2? Also, how high resolution assets mentioned in blog are supposed to work? Can I just first set the size of my stage/window to some multiply of my "default resolution" and then load higher resolution assets and everything "just works" without having to consider coordinates transformation and individual sprite scaling? For example if I develop on resolution 800x450 and set sprite to center of the screen with something like MySprite(400,225), will the sprite appear in center of the screen when game is scaled to 1920x1080 and uses different resolution asset?
  5. @jcs Thanks for elaboration. I think I got it now @CaueCR Yeah, after posting this thread I found the minifying concept. About the Brackets error, I knew it wouldn't affect the game but I like to keep my error-log in check so that when something important comes up I notice it jcs' jshint conf-example fixed the problem for me.
  6. I'd suggest adding more visible links to few tutorials and wiki into phaser.io site. I found the first game tutorial by accident and I think that this kind of material should be easily accessible via main site.
  7. From quick look I think that you shouldn't do this on update nor in create: menu = new Menu(game);Second, in the menu.js you place the position of the sprite to x: 800 y: 800 when I think it should be (0,0). After those changes I got it working with my local files.
  8. Note that this same problem applies to Flash games too. It isn't exactly difficult to decompile and steal a Flash game from mentioned service if one is inclined to do so. However, as far as I know those incidents are rather rare in FGL so I think you can trust the "honor code" of the place. Other than that I don't know exactly how html5 game sponsorships work there. Also, the open source and assets stuff applies to Flash games too (except that html5 is a bit easier) but afaik it's quite rare so it's probably not worth to worry about. More important is to prevent simple hacking by changing variables via browser's developer tools. For this you probably need some server-side logic like a_bertrand said. Then again I wouldn't bother with it unless the game is competitive and has online highscores which require server anyway.
  9. @Chimera Thanks, I'll definitely take a look into those states and try to figure out how they exactly work. The concept is familiar to me, it's really the implementation and usage which I'm not yet familiar. @jcs Thanks you for example code. Interesting pattern. Just to ensure that I figured it out correctly: you basically create a namespace function/class which has the require function. This function then checks if the required module is appropriate. I'm not sure if I understand what's happening here though: // prevent re-load var m = loaded[modules[i]]; if( !m ) { m = myNamespace[modules[i] || modules[i]; if( !(m instanceof Function) ) throw new Error( "Unknown module '" + m + "' passed as module to require()" ); m( X );What exactly goes to the "m" variable in first line? A module name if it exists in the loaded array? Otherwise "m" is going to be undefined and the if-statement is executed. I'm not sure what happens next. What is the difference between myNamespace[modules and modules? Where do myNamespace[...] refer? Error check looks straightforward. m( X ) is used to pass the namespace object to the module? In the module file you then inject module's functions to the specified namespace by using provided X pointer. In final use case the user of the namespace asks the namespace to provide requested functions/classes by X.require which then retrieves missing required classes and adds them to the namespace. Am I right? It seems rather clever system. Is there any wide used name for this kind of pattern?
  10. For me the confusing part in web development in general is the myriad of tools and their relationships. However, it looks like that when using Phaser and developing only canvas games, one probably doesn't need to wade too deep into web-development. Or at least that's how it looks like to me, but I'm novice with js/html5.
  11. Thank for responses! @Chimera So this state thing is a part of Phaser? Interesting, I have to look into docs if I can make sense of it. Thank you for mentioning it. If anyone knows good explanation of how to use them I'd like to hear. @jcs Could you explain that require method a bit? I have seen few such kind of things in internet but haven't really studied it. Is it just a tag for separate tool (grunt?) to use while concatenating the files? Good to know about performance. Not sure how much I have to worry about it atm, since most of my games are rather slow paced.
  12. In past I have developed games on Actionscript, Game Maker, C++ and various other languages. Recently I decided to jump into javascript and html5 and found Phaser. While JS in general seems rather straightforward and Phaser handy looking library, I need some clarification with some practices. While some questions are a bit more general, I'm going to work in Phaser context (which is why I posted this here). 1) How exactly I should organize my code during the development? I don't want to edit one huge html-file with inline js but instead separate different classes to different js-files for maintainability. After studying js, I noticed that there isn't such concept as "includes" or "imports" as in Java, Actionscript etc. Apparently I have to use some external tools to concatenate the files? If so, what is the best practice when using Phaser? Or should I just make a list of <script> tags to the index.html and try to introduce them in order they probably are going to used? That might create rather long list if each class has its own file... 2) I installed Brackets editor which seemed like best option for me for JS coding. I'm using JSHint to help me to learn the proper syntax & cleanliness of the code. Now, this is minor issue but I always get errors like these from js files such as load an image example: How I should define the Phaser to avoid this error? 3) How much I have to worry about browser compatibility in general? Is most of the relevant stuff abstracted in Phaser? Like as long as I use the library as intended and avoid special things everything should work? Not saying that I'm not going to test my games on different browsers but I'd like to know this in advance Thanks. Also, if you feel like this isn't Phaser relevant enough, feel free to move it to the more general board. EDIT: I found this simple tutorial about how to split things to multiple code files: http://toastedware.com/?p=258 While it answered to how to split things, what confuses me a bit is how I should handle pasting them together. If I'm right, using multiple separate js-files will increase loading time of the game, so I'm not entirely convinced to just put full list of all of my classes to one long <script> tag list in the head of the html-document.