Yehuda Katz

  • Content Count

  • Joined

  • Last visited

Everything posted by Yehuda Katz

  1. @damager thanks for sample, I bookmarked topic for future reference. Did I understand your code correctly? You already have one image with six different puzzle pieces. If that's true, why you do not want convert them in sprite in advance? What's the advantage of doing it after loading it as sprite first? As for the font drawing, Phaser has one strange thing... I cannot find that post on forum but the example was following. There were two buttons (sprite and text above it). If you draw first sprite, font and after second sprite and text, you will get slower result than if you draw both sprites and after both fonts (because drawing font causing draw call, since texture changes). While I was searching for that link, I came across to this old post I hope it will be handy (I will go refresh my knowladge as well :))
  2. @microspace Despite that reset is widely used in tutories, I personally faced many strange behaviours of it. It does almost nothing special and if you need to move sprite back, better do it yourself. As you can see reset itself does something which may not important for your case and you are losing CPU time.
  3. @damager try this short tutorial and trial of app. Anyone who does games soon or later switch to atlases there is also free alternative but with less easy to understand interface:
  4. @dude78 sometimes it looks like this forum is dead What do you mean by changing sprite bounds? You cannot change texture size but you can change size of sprite which uses it. Lets say you have 'character.png' image 100x200 pixels size. Once you load it, it will have 100x200 pixel size texture. You can create sprite using this texture and by default it will be also 100x200 but you can easily change its width/height by my_sprite.width =150 or my_sprite.scale.x = 0.7 to make its width 100*0.7 = 70 pixels. That will change sprite's bounds... also you can directly change x/y propery of sprite to move it around screen and that will also affect bounds. If I understand your question wrongly, just let me know.
  5. @makis actually if you compare svg vs png, I would say svg is much better However, it's all about how you keep your resources. The downside of svg is that it requires CPU to get rendered, that's why it's not activly used. Game developers even trying to reduce transparen pixels in sprite (png image) by using triangular polygons (unfortunately phaserdoes not support them yet). Anyway, Phaser looks way complicated and difficult untill you spend at least half/one year with it. BTW here is the creator of PhaserEditor @PhaserEditor2D. It's kind of GameMaker but simpler and uses Phaser. The advantage of Phaser vs GameMaker is that it uses JS, which has tons of Q/A on stackoverflow. There is also mightyeditor... it looks awesome from demo videos but I personally never used it. I prefer custom/own editors/solutions, simply because I can easily change/upgrade them at any time. However, GameMaker is almost only GUI... that's not acceptable for real game developers but could be a good start for you. I am learning all editors and technologies to get the best out of each but since game development is not your job and just a hobby, start with gui and once it will not be enought, switch to technology which requires more codding
  6. Espace, you cannot see the difference if you use a group from CPU point of view. However the difference exist simply because lets say your both sprites are in, if you use wrapper group it means they are inside so it means when Phaser will need to calculate where to draw sprites, it should first get local bounds of group and apply them sprite's x/y. Those calculation are so simple that I would prefer use group which makes code simpler and easier to understand. Therefor there is a less chance to make more important, logical mistake in future when games gets bigger 😃
  7. Hello, I have my own scrolling for container, everything worked fine until: I had popup with scrolling over background which could be scrolled as well 😃 The issue is obvious: while I am scrolling popup, the background is also scrolling. Of course I can improve code and check that pointer down was over container but there are over elements which grab mouse down event and prevents it to be passed to the bottom container. Is there any pattern to resolve this issue? Thanks
  8. Oh... in that case you should give a try to GameMaker. Almost everything can be done only visually and they have great video tutorials. I have no idea how good you are with software development but anyway you will enjoy this game on your mobile/table There is also much more complicated game on Steam... you can write pretty nice games using only your imagination and finger. If you are really interested just let me know and I will search for it.
  9. You are right... actually your mistake was to select Phaser3 while it's under active development. I could assure you that even Phaser2 has lots of bugs but you can deal with most of them (amazon has couple of interesting books). If you want to be a good game developer you need time (at least couple of years). Learn Phaser, GameMaker, Unity, Defold to get the best out of their tools because finally you will end up creating your own engine. Once you spend enough time with Phaser you will understand that it's all about: sprite and group 😃 plus simple physics. However, if you are new to game development, starting with PIXI is something like starting with Assembler (who remembers it now?) while you are still unfamiliar with C.
  10. This is the only 3rd party plugin I am still using but I think having some pure HTML inputbox while game fades out would be much better. Just imagine the situation, the input is at th bottom of the screen... native keyboard will overlay the input so user cannot see what she is typing. If you do not do this and your implemented your game so it scales to mobile screen size, you can guess what user will see
  11. @farhan out of curioucity, when you mentioned about custom state manager, I decided to check how Phaser is doing that and is there a way to tell it to skip some? So basically Phaser with clearWorld parameter enabled is dong two things: resets scale and shutdowns the world... and here is what shutdown of the world means: // World is a Group, so run a soft destruction on this and all children. Awesome, did you got the point? So basically set resetWorld to false and once new state will be started, in its init/preload even you can clean up (destroy) world (the children of previous state) which you do not need by simply calling, true). I have not tested this solution yet but I will give it a try with one of the next game's update.
  12. @Appolos you should have global object which will be accessable from all states. I assume you have global variable game, so you can create another global object like profile = {health:100, coin:0} and store all data there. I personally prefer to store all global objects within game object. So it looks like game.profile = {health:100, coin:0} and I also have game.translate_manager, game.tween_manager and etc. Those objects are kind of libraries, they store data during the game and can be easily accessed because game object isaccessable everywhere probably I should use plugin property instead but official doc gives little guids regarding game structure.
  13. @farhan the issue you face is related to how you switch between states. The first option sets the state you want to start but the rest is used to tell Phaser if all objected created in current state should bedestoyed (default). Since you created group it will be automatically destroyed (to clear memory from junk). The only solution is to tell state manager not yo clear BUT I would not suggest todo that because in that case you will have new state over old one, plus you have to clear memory from unnassasary objects yourself. That's way complicated... so simply recreate the group. Unity for example has option to set one particular object to be preserved, Phaser so far does not have (at least I have not found it yet). As for @dude78 suggestion - that's also very handy, if you need to pass some local parameters for state but user profile or something bigger should be stored as global variable just like you did it.
  14. @Appolos There is a little chance to get answer here since the issue is not related to Phaser or even web requests. You should try official support.
  15. @rich is absolutely right and even more @damager, you can speed up texture atlases too I am sure you will enjoy the article, as it will explain how everything works behind the scene.
  16. You should not use text bounds, they are useful if you have some kind of container within which you want align your text (especially if it's multi-line). For your case anchor is the best option: this.menuText =,, 'sample', {font: '60px Arial', fill: '#ffffff'}); this.menuText.anchor.set(0.5, 0.5); this.menuText =, 0, 'sample', {font: '60px Arial', fill: '#ffffff'}); this.menuText.left =; =; this.menuText.anchor.set(0.5, 0.5); this.menuText =,, "sample\nthis is a new line", {font: '60px Arial', fill: '#ffffff', align: 'center'}); this.menuText.anchor.set(0.5, 0.5); The first one is just for single line text, the second sample should help you understand what I did in first one. The third sample shows how to center multi-line text... anchor sets the center point of any object. The 0 means left or top, 1 means right or bottom... any value between those will move object's x/y coordinates within object.
  17. @weil You can do it indirectly. Create BitmapData with key as @samme thought and draw texture on it. You cannot draw texture but you can draw its canvas. This should work: var bmd = new Phaser.BitmapData(, 'texture_key', graphics.width, graphics.height); bmd.draw(graphics.generateTexture().getCanvas());
  18. Thanks, that's exactly what I was looking for 😃
  19. Hello, Is there any way to force Phase to update texture without a delay? Shortly said, I have issue with Phaser.Group.generateTexture() method: 1) Lets say you have group, which fade out to alpha = 0. 2) Later you want set group back to alpha = 1 and 3) generate sprite, 0, group.generateTexture()) RESULT: you will get empty sprite... However, if I do lets say 100ms delay, everything works as expected... If I fade out group to 0.1 instead of 0, I am getting texture with 0.1 transparency, which means that PIXI needs time (one tick?) to actually update alpha. QUESTION: Is there any way to fix this problem? Thanks
  20. You are absolutely right. I wasted over 4 hours trying to understand what is going wrong and why input is not longer working. It took me 3 hours to find that once cacheAsBitmap is enabled, group's left, top coordinates reset to parent group. I was suspicious about that because in PIXI.Graphics.prototype._generateCachedSprite I found this line var bounds = this.getLocalBounds(); WHICH (getLocalBounds) NEVER WORKS IN PHASER, NEVER EVER! So far I have no clue how to fix it but I am happy that I could reproduce error and narrow it parent group. Simplified example to reproduce error: var parent_group = new Phaser.Group(; = 100; parent_group.left = 100; var group = new Phaser.Group(, parent_group); var sprite = new Phaser.Sprite(, 200, 200, 'sprite'); sprite.inputEnabled = true; { console.log('click'); }, this); group.addChild(sprite); group.cacheAsBitmap = true; To get log messages you should click top left of the image (-100, -100). The solution you suggested did not work for me but I used your idea and did following: I simply set all parent group's coordinates to 0, 0 and instead of moving parent, I moved cached group to appropriate position and it worked. Of course bug in Phase still exist, but I am still using 2.6.2 May be in later releases the problem was resolved. Second solution I found is to add wrapper group which will hold the cached group, this solution also worked for me. However, I am thinking to create my own simple cache method which will set all children of group invisible and adds new sprite created with texture generated out of group 😃
  21. This forums seems to be useless... you can find solution in sources codes of Phaser faster than here
  22. @JohnXu sure give a try to second version, I am using v2.6.2 for almost a year. It has bugs but I will never change it because I have no idea what new bugs are waiting me in new version 😃 BTW the only reason sprite may not get input is another sprite over it. Are you sure that you do not have any overlapping/transparent objects over that text sprite? Try to remove all code except the one which generates that sprite and then give a shot. To be sure that nothing else is interrupting main code.
  23. @JohnXu then I assume you are using Phaser3, am I right? If that's true then it could be some bug, but lets debug it step by step. Please try this: () { console.log('general tap'); }, this); Lets be sure that we are able to accept taps and there is no issues with input itself (as you can set how many pointers should be tracked by Phaser and bla bla bla)
  24. @JohnXu could you please clarify, when you tap on textSprite, can you see console log message? () { console.log('tap dispatched') }, this) If you cannot see log message, can you see text sprite itself on screen?
  25. @JohnXu you set InputDown event correctly. Take in an account your comment, the console.log() event is also handled successfully. So the problem seems to be with game state change. Could you please show how do you do it? game.state.add('new_stage', NewStage);'new_stage', true, false, some_custom_var); Please try to refer to game object via instead of just game Waiting for your reply