Search the Community
Showing results for tags 'visible'.
-
Hi, I have several buttons in my game and I want them to disappear when I click on it. But it seems that the event "onInputOut" is not fired when I set the property button.visible = false in the callback function of the button. Is this a normal behaviour ? Because this causes some problems in my game logic. Is there a way to force the event "onInputOut" to be launched ? I tried button.onInputOut.dispatch() but it does not work. Thanks
-
Hey! I've been getting started on developing a game for Phaser, and I've run into an issue. It's a bit hard to describe, but I linked an image of my game to kind of describe it. The balls that you see on screen are meant to go inside that box. They move across the screen. I want them to not be visible outside the box, that way it looks like they ease into it. The problem is, I'm not sure how to do this without it going over my background (the lines that you see on the outside of the box). How can I make it so the sprite is only visible inside the box?
-
I'm working on a game project where I want to be able to switch between two "dimensions" in the same world. I though the easiest way to do this was to have a keyboard event, which toggles sprites' visibility when pressed. This works fine, however, when the visibility is toggled off, and I move the character (and thus, the camera), the sprites seem to be keeping their position relative to the camera, and not the world. Which means that when I toggle the visibility on again, the sprites have moved from their original position relative to the world, but are in the same position relative to the camera. For example, if a sprite is off-camera while invisible and I move the character, the sprite gets pushed off the stage, and can't get back (because it falls down below the ground). How do I stop this from happening? How can I "lock" them in place while visible? I read that the sprites are not being rendered when visible=false, so should I be using some other method of hiding them? Here is my relevant code for the keyboard event: skey = this.game.input.keyboard.addKey(83); skey.onDown.add(this.sPressed,this); Here is the method sPressed: sPressed: function(key) { if (baddie.visible) baddie.visible = false; else baddie.visible = true; if (stars.visible) stars.visible = false; else stars.visible = true; } And here is how I make the camera follow the character sprite: this.game.camera.x = player.body.x-200; I tried changing to camera.follow, and camera.focusOnXY, and that changed nothing. I have tried googling, and can't find anything relevant to my problem.
-
Hi, I'm creating my first project with Phaser. I have two large background TileSprites that I want to toggle between as the game is played. When the game state calls the create() method it creates the sprites and then sets one visible true and the other false. After a set time, it will swap. The first time this swap is called, there's a bit of lag. Subsequent swaps have no lag. I've experiencing this on my Nexus 5X and Laptop (Core i7 + GTX960M). I'm guessing that because I almost immediately set visible to false, the second sprite isn't being rendered to the GPU. Once it has rendered at least one time, then subsequent calls to toggle the visibility don't lag cause the texture is somehow cached. This is all conjecture on my part, I really don't know how these things work. Is there anyway to cache a sprite/texture to the GPU, so that toggling the visibility won't cause lag? Thanks!
-
Hello, We are making a game with Phaser and works perfect in all the browsers except in Safari (iPad). It's pretty strange becouse the game seems to be running becouse we can hear the music, but the canvas is not displayed... Few seconds later the game is destroyed... We can't use the remote debugging becouse we don't have any Mac to conect the IPad... (Phaser Version: 2.6.2 / IOS version: 9.3.2) Please help!! Thank you
-
Hello & Thanks , In code below : Runs fine as is . But I would like to run it without game.debug.geom(rectA, '#ff0000'); . If I do , then rectA is not visible . How can I run it with no game.debug.geom(rectA, '#ff0000'); and rectA is still visible ? Thanks
-
Hi everyone, I'm noticing refresh freezes when showing items (loaded, but with visible set to false). With freeze I mean that although normally the game works with 60fps, when showing new item (loaded but not visible) it takes 300ms to call another render. My loop is simple and looks like the following: function render() { update(); renderer.render( container ); // render stage requestAnimationFrame( render );}I logged the render function to output time from the previous render and it returns 300ms when the problematic event occurs. I tested every single line and it came down to a single line: sprite.visible = true;This sprite is made visible through keyboard event (when space is pressed) and it is the single line of code being called. The texture for the sprite is loaded at the beginning by using PIXI.loader with event complete that instantiates the sprite object, closes the loading screen and shows the stage (container object, I'm using pixi 3.0.6). As follows: PIXI.loader.add("mysprite","sprite.jpg").once('complete',function(){ sprite = new PIXI.Sprite( loader.resources.mysprite.texture ); sprite.position.set( 100, 100 ); container.addChild( sprite );}).load();So why does it take so much time to render the object, it is loaded just not visible. Is there a workaround, like preloading (am I not doing that already?), I mean, this 300ms freeze is just too noticable. One more thing. It happens only on the first time the sprite is shown, later everything runs smoothly. I am testing with Chrome 43 (I tested the example with Chrome 43, IE11 doesn't seem to have a delay), same thing happens on Android after compiling with CocoonJS. Thanks.
-
Hello everyone, after time of searching, I just can't figure out what's wrong. Look at this: http://www.babylonjs-playground.com/#2EMDUN I'm trying to load a reflectiontxture, but I'll never see any "reflection". In materialeditor, everything works , but it doesn't in my project or the playground. Am I missing something? Thanks, Kevin
- 3 replies
-
- reflection
- texture
-
(and 2 more)
Tagged with:
-
Hi! One and quick question... Using groups, is there any diference (in terms of performance) between phaserGroup.alpha = 0;and phaserGroup.visible = 0;? This question is also extensible to sprites... Thanks
-
Hi everyone! Still a big fan of Phaser and coming back for another question! Here is my problem : in my game there are two maps (that should be considered fully different). It is possible for a character to go from one map to the other. The best way to picture this would be, for example, a bonus level within a normal level : you jump in a magic pipe and you land in the second 'bonus' map. But the first map still exists : and everything contained within shall be updated, as the character may go back to it anytime (or other players may still be in it). I have managed to create two different maps, and I have managed to make my character travel from one map to the other (back and forth), through the "R" key for the moment (no need for a magic pipe yet ). But my characters (both the 'main', playable one, and the 'bot', test one) have a very weird behavior regarding collisions. I can't make them collide with both maps' grounds. And when I eventualy do, travelling from one map to the other breaks it all. The 'bot' goes through the floor and even falls from the sky sometimes! What is even more bizarre is that the debug green 'hitbox' does not seem to reflect what the debug info display. I can see the box in the scene whereas the y coordinates displayed can be 20 000 or more. Who shall I trust? Playing with the TILE_BIAS property also gives mysterious behaviors. If I totaly remove it, the 'bot' will fall through the floor on the first main char map-switch, but then will never fall lower than the map's bottom bound. As I am quite new to Phaser I won't call for a bug that soon, but rather for a bad coding from me. I can't wait to solve this problem and successfuly code this pretty simple setup the good way. I have attached the project herewith. Any help would be greatly appreciated! PS : for simplicity's sake, the two maps are identical, only the colors change. The maps' files (images, tilesets etc.), however, are different, so that the weird behavior might not come from here.PhaserDemo.zip
-
I've been checking the source code and I could not find anything, so I'm wondering, is it necessary for the developer to make calculations on which elements are currently inside the camera view, and which are not, in order to change their "visible" property and improve rendering performance, or does Phaser already handle that?
-
Hey guys, In my game I hide some sprites by setting their visible setting to false. Problem is, my collision detection still detects if these invisible sprites are getting hit. I would like to know how I can make the collision detection ignore them. Recently I've seen a option on these forums which was something like sprite.collision = false. I think it was an option to ignore the collision of a certain sprite. Too bad I can't find that post or option anymore, so that's why I'm making a new post about it. Hope anyone can help me, otherwise I'll have to write my own detection for just visible sprites but enabling some kind of option would be much easier. Thanks, Kevin
-
I have a button that I want to 'disappear' when it's clicked (moving to a different scene) so I use... this.items.setAll("visible", false); this.items.setAll("exists", false); (items is a group holding all buttons for the scene) ...which works fine. The problem is that the mouse cursor then remains in the 'hand' state until you move over and out of a different button. Any ideas on how to handle this? It's not a massive issue, just looks a bit odd.
-
Hey guys, first time posting here. I have a black background sprite that appears when my game is paused to fade out the screen. In the create function I create it, set its alpha to 0.5, and set its visible value to false (I also put the body to null if that makes a difference). When the paused button is pressed, I set its visible property to true and pause the game. In my update function I set its visible to false, so that when the game isn't paused, the background is hidden. For some reason this doesn't work the first time I pause the game, but it works every time after that. It just really bothers me. Is there something I'm missing? Thank you.