Popular Content

Showing content with the highest reputation on 05/25/14 in all areas

  1. 1 point
    I have a DisplayObjectContainer full of tiles that the user can pan around and explore. At the moment all the tiles are in a DisplayObjectContainer at all times, but I'm wondering whether Pixi does any optimisation around not rendering items off the screen. Should I should be more aggressive about adding & removing items from the stage when they're out of view?
  2. 1 point

    Dynamic mesh not rendering

    Thanks Deltakosh! Ok, Speps, in order for dynMesh.updateVerticesData to work, I had to revert back to the older way of creating dynMesh... where the mesh carries its data WITH it. (In the newer version that uses a 2-object method, the VertexData object sort of "casts" the data into the shape of the mesh, but the mesh doesn't carry the data with it). (As I understand all this). So, since I have been pasting the thread full of code to this point, I might as well maintain that habit. <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Speps Dynamic Mesh Test</title> <script src="./js/hand.minified-1.3.7.js"></script> <script src="./js/babylon.1.11.0.js"></script> <style type="text/css"> html,body,#canvas { width:100%; height:100%; padding:0; margin:0; overflow: hidden; background-color: black; } #button { color: white; font-size: 14pt; font-weight: bold; padding-left:4pt; padding-right:4pt; background-color: red; border: red outset 3pt; line-height: 2em; cursor: pointer; } </style></head><body> <div id="buttonbar" style="background-color: rgb(55, 55, 75);"> <span id="button" onclick="changeit()"> click me </span> </div> <canvas id="canvas"></canvas> <script> var which = "original"; var canvas = document.getElementById("canvas"); // Check support if (!BABYLON.Engine.isSupported()) { window.alert('Browser not supported'); } else { var engine = new BABYLON.Engine(canvas, true); var scene = createScene(engine); engine.runRenderLoop(function () { scene.render(); }); // Be ready for a window resize window.addEventListener("resize", function () { engine.resize(); });}// ------------------------------------------function createScene(engine) { var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 5, new BABYLON.Vector3(0, 0, 0), scene); var light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 1, 1), scene); scene.activeCamera.attachControl(canvas); createDynMesh(scene); return scene;}// ------------------------------------------function createDynMesh(scene) { var dynMesh = new BABYLON.Mesh("dynMesh", scene, true); dynMesh.setVerticesData([-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0], BABYLON.VertexBuffer.PositionKind, true); dynMesh.setVerticesData([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0], BABYLON.VertexBuffer.NormalKind, true); dynMesh.setIndices([0, 2, 1, 3, 2, 0]);}// ------------------------------------------function changeit() { var scene = engine.scenes[0]; var dynMesh = scene.getMeshByName("dynMesh"); if (which == "modified") { var positions = [-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0]; var normals = [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0]; var indices = [0, 2, 1, 3, 2, 0]; dynMesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions); dynMesh.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals); dynMesh.setIndices(indices); which = "original"; console.log("changed it to original"); } else { var positions = [-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0]; var normals = [0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0]; var indices = [0, 2, 1, 3, 2, 0]; dynMesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions); dynMesh.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals); dynMesh.setIndices(indices); which = "modified"; console.log("changed it to modified"); }}// ------------------------------------------</script></body></html>This seems to work just fine. Thanks for bringing-up this subject, because I was able to learn some things with you. I hope I did not ruin the fun of your experiment by pasting this code. As Deltakosh mentioned, your experiment is also promoting the addition of a new function on the VertexData object... a sister to .applyToMesh() ...called .updateMesh(). Congratulations on your contribution to the babylon.js framework! That is quite a good accomplishment for someone who is so new to the forum! Well done!
  3. 1 point

    Timer with named function

    You should use bind. init: function() { this.addTimer(1000, this.my_timer.bind(this), true);}
  4. 1 point

    Two Keys at Once (e.g. Move & Fire)

    if (this.cursors.left.isDown){ this.player.body.velocity.x = -100; this.player.animations.play('left'); }else if(this.cursors.right.isDown){ this.player.body.velocity.x = 100; this.player.animations.play('right'); }else if(this.cursors.up.isDown && this.cursors.left.isDown){ this.player.animations.play('cast-large-right'); }else if(this.key_c.isDown){ this.player.animations.play('cast-large-left'); }else{ this.player.animations.stop(); this.player.frame = 78; } With that code if the left key is down the rest doesnt get checked including..... }else if(this.cursors.up.isDown && this.cursors.left.isDown){ ...and..... }else if(this.key_c.isDown){ ...."else" is your problem EDIT : I think you want something like this..... if (this.cursors.left.isDown) { this.player.body.velocity.x = -100; this.player.animations.play('left'); } else if (this.cursors.right.isDown) { this.player.body.velocity.x = 100; this.player.animations.play('right'); } else { this.player.animations.stop(); this.player.frame = 78; } if (this.key_c.isDown) { if (this.cursors.right.isDown) this.player.animations.play('cast-large-right'); else if (this.cursors.left.isDown) this.player.animations.play('cast-large-left'); // else shoot in the direction their facing }
  5. 1 point

    [ask] How to Rotate point with image

    Im not going to answer this but just wanted to say.... Your getting into the realms of "code this for me"....I hate that crap. If you want people to try and "fix" your code, not "write" it, then show us some code!!!! Create a simple example in JsBin or CodeIo of woteva and then people like me would be perfectly happy to fix it. @XekeDeath : Love the sig Got a mate who created a career as a coder using that advice....being an Aussie I wonder if he taught you
  6. 1 point
    It's may be good start point for you. app.ts game.ts boot.ts preloader.ts I see no reason to post menu and levels.
  7. 1 point

    GM:Studio - Beware update 1.3.1307

    If it ain't broken...
  8. 1 point

    [ask] How to Rotate point with image

    Maybe if there was a question attached to it.
  9. 1 point
    @Videlais: Thanks for contacting Ludei directly. That's great news since it sounds like we can actually fix it. What I don't get is why they didn't answer publicly to my request, which, by now, has six votes and two more comments with people sharing the issue. Especially, since they obviously know the answer to that one, I don't know what actually kept them from letting us know. Quite disappointing. If I'd had that information a week ago, I may not have lost a day fixing things manually by replacing TileSprites and stuff. Oh well... for the next project. In other news: I was struggeling with sound under CocoonJS again on the week end. It turned out that everything behaves quite differently if you don't trigger the sounds directly on start up. Essentially, nothing worked reliably at all. Sometimes the sounds would play, sometimes not. There didn't seem to be a pattern except one: If I tapped before or at the beginning of the load process we had more, if not all sounds play. So, eventually, I tried this and it did the trick: Before preloading any audio (so actually in my Boot state), I sneak touch input from the player by letting him choose whether she wants to start a new game or continue the old one. After that selection I load everything I didn't need at that point, including all audio (that first click has to go silent) displaying the preloader and sound always works reliably afterwards. That actually solved all of our problems. It seems that sound just won't work reliably if you don't get user input before preloading the audio files (and Phaser probably does something in the background that should be done after the touch occured). Also, I've stuck with WAV for now, since it works on both Android and iOS but played back cleanest on iOS, especially when looped. Looping in general, sadly, still is an issue, though. I've experienced quite some lags when looping on Android (Nexus 7 1Gen and Nexus 5). Sound playback works actually way better within Chrome on both devices. Well, but it all looks way better than only a week ago now. And though I've had some very frustrating moments with CocoonJS up until now I'm quite happy with what I submitted to the App Store yesterday Let's hope all of this improves some more turns into actual fun into the very near future Note: I'll update my above posts concerning audio, so they're not misleading. EDIT: Just a thought: it may be enough to add the audios to the game (via game.add.sound) after the first click occured. I'm not sure I've checked that. Then again I've checked so much this week end I'd be surprised if I hadn't tried that option. Well, if somebody cares to give it a shot, I'd be curious about the results.
  10. 1 point
    I was just looking into this, I found the most obvious way was to add the filter to the stage, i.e. this.game.stage.filters = [this.filter]; Not sure if that's best practice or not but it works well. ** Edit ** I actually applied the filter the world in the end, rather than the stage, as I believe this is disposed of when you move between states.
  11. 1 point
    Good news, everyone: I got audio to work! (Within the CocoonJS Launcher. Will check compiled app and reconfirm. EDIT: Works!). Thanks to an idea from @Haden (thanks again for that), I found out that M4A isn't even supported under CocoonJS - not even on iOS. So here goes: Setup (as mentioned above): - Phaser 2.0.4 (Canvas+) - CocoonJS 2.0.0 - iPhone 5 iOS 7.1.1 1. I tested M4A, WAV, MP3 and OGG. M4A wasn't even loaded and only MP3 and OGG did actually play back. EDIT: We have MP3, OGG, WAV on iOS, OGG and WAV on Android. 2. Just like in some other mobile browsers, playback only worked after one initial touch, after preload was complete. EDIT: It turned out to be absolutely essential this touch happens BEFORE any audios are being loaded into the game. See this post for details. 3. A previous muted playback as suggested by @Haden in the above post, was not necessary. EDIT: Still isn't if you get touch input before loading. 4. Simultaneous playback of multiple audios works (I tested with two). 5. I experienced some slight lags between playbacks when looping. The lags appeared more frequent the longer the audio was. These may be different for CocoonJS 1.4.7 and other versions of Phaser. What. A. Day! I guess, I can go home and sleep soundly now. @videlias: You may have to update some stuff on the front page.