Search the Community
Showing results for tags 'event listeners'.
-
In my main scene I add keyboard event listeners to specific keys in the init() state. Also some of those keys need to be disabled at specific time and re-enabled at specific time. How can I disable/enable input on specific keyboard buttons at runtime?
-
Hello. I managed to create code that draws a button along with a textfield and also with the four states that a button have, onInputUp, onInputDown, onInputOver and onInputOut. However, it is still experimental, and since I add text object as a child of Phaser.Graphics, the text is a bit blurry. But the bigger issue is, new graphical elements are added without removal, so I have a bug somewhere, or it is just not possbile to create dynamically drawn button with text and all states and to add custom click event handler. I will post another topic for the code itself, but here i just want to ask if there is a plugin for Phaser that draws buttons dynamically, or buttons on which I can change the text dynamically? Or how can I create button and be able to change its text dynamically? Should I just place Graphics object below and on top a text field both pointing to the same click listener?
- 1 reply
-
- phaser 2.6.1
- graphics
-
(and 3 more)
Tagged with:
-
While I was learning the documentation I decided to experiment with the code for a bit. and I encountered a problem. I attempted to make a function that makes a new box, then I would make an HTML Button and when clicking this button the function that I made should be triggered and a box should appear on the screen. Since this didnt work I decided to see if you guys could possibly help me. Here is the code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script> <script src="http://www.babylonjs.com/cannon.js"></script> <script src="http://www.babylonjs.com/oimo.js"></script> <script src="http://www.babylonjs.com/babylon.js"></script> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; } #renderCanvas { width: 100%; height: 100%; } #mainDiv { background-color: green; width: 100px; height: 100px; position: relative; bottom: 300px; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); var camera = new BABYLON.FreeCamera("VJ_camera", new BABYLON.Vector3(0, 1, 0), scene); camera.attachControl(canvas, true); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); var ground = BABYLON.Mesh.CreateGround("ground1", 100, 100, 2, scene); function random() { var box = new BABYLON.Mesh.CreateBox("box1", 2.0, scene); } return scene; }; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); }); </script> <div id="mainDiv" > <button onclick="random()">A button</button> </div> </body> </html> I'm new to Babylon and also to this forum, though I checked my code several times there might be something that I missed. And I will say this ahead of time. Thanks!
-
how to add event listeners for objects in scene loaded from blender
-
- babylon.js
- event listeners
-
(and 1 more)
Tagged with: