wombat

Members
  • Content Count

    21
  • Joined

  • Last visited

Everything posted by wombat

  1. @Yanifska: I'd like to help but I don't remember. The .ogg files were created in Audacity, and if I load one back it says Stereo, 44100Hz, 16-bit PCM. I don't know if that's the setting your'e asking about. The link above is still valid though if you want to have a look at the .ogg files yourself.
  2. Hi, I'm not sure what you mean by getting Phaser.io to work on cloud9, so I'll tell what I know and hope what you need it's in there somewhere. This is how to copy all the Phaser examples to cloud9 to play around with 1. Your project has to be public, otherwise you won't be able to view it 2. Just supplying the url of the github repository when creating a new project doesn't work I think , instead, create a new empty project, (public!) and clone the repository from the command-line, ie enter git clone https://github.com/photonstorm/phaser-examples.git3. To view the examples, you open the index.html file in the editor (it's in the examples/ directory) and click "preview". This will open the page in the browser. 4. If what you wanted was just to get your own project to run in cloud9, it's the same procedure. Create an index.html file that loads phaser.js and your own js files, and "preview" the index.html file. 5. There's a post around here somewhere where I got help with the same problem, but I can't find it now. I use Chrome, I belive there was some additional weirdness when I tried do this in Firefox.
  3. ...here's something that works, kind of: sprite.anchor.setTo(1.6, 0.45);although it expresses the offset in sprite dimensions ("draw top left corner 1.6 times sprite.width to the left of center") so it's a bit tricky to get right. Also it's a PIXI.Sprite attribute so I don't know if it's safe to mess with it. @CtlAltDel When I tried that there was a lag, so I thought that when I moved the camera in the update() I was out of sync with the world's movements. When the sprite was accelerating/decelerating (fast) it would change its position on the screen. When I set the anchor as above it doesn't do this. I believe that's because the camera position isn't normally updated in the update() function? @Heppell08 As I understand it the camera follow styles define an area of the screen in which the sprite can move without the camera following (i e without the background and other sprites scrolling). Perhaps I can define a really small area (1x1 pixel perhaps) at the place where I want the sprite to be 'locked'? I'll give it a try, though maybe I'm not really understanding how it's supposed to work. Edit: Ta-da! game.camera.deadzone = new Phaser.Rectangle(200,380,1,1);
  4. Thank you, but specifying Phaser.Camera.FOLLOW_LOCKON changes nothing. It's the default value. // Phaser.Camera sourcefollow: function (target, style) { if (typeof style === "undefined") { style = Phaser.Camera.FOLLOW_LOCKON; }
  5. That's interesting. How do I know when I have to worry about objects not being initialized? Can I be sure that if the objects have time enough to initialize on my computer, the code will work on any computer? Or should I always put a setTimeOut statement after I create the game object? Should I do some kind of testing to find out if there are other places in the code where this could happen?
  6. Hi all, I want to make the camera follow a sprite so that the sprite is always in the same position on the screen. Updating the camera's position in the 'update' works, but with a lag (i e when the player is moving fast the surrounding doesn't catch up with the sprite immediately. Not working 1: // in the 'update' functiongame.camera.setPosition(this.player.sprite.x - 10, this.player.sprite.y - 50);Setting the camera to follow the sprite does what I want, except that the upper left corner of the sprite is in the center of the screen. Not working 2: game.camera.follow(this.player.sprite);Then I thought I could make my player sprite a child of a group, add another (invisible) sprite to the group at an offset, and have the camera follow the invisible sprite. I want the player to have a physics body however, and from what I understand I cant enable physics on the parent Group. (I can pass the group to game.physics.enable, but there's no 'body' set on the group). Out of ideas. How can I make the camera 'follow' the sprite, instantly, but with an offset?
  7. Thank you. Since I believe the .ogg files are loaded as first choice, I guess there's something with the encoding of these that the native browser doesn't like. Not loading these (using just mp3) works, until I figure out what is wrong with the oggs. EDIT: Turns out I didn't change that at all, I only thought I did. Instead, sound seems to have started working mysteriously on it's own accord. Hm. Sorry for wasting your time folks, if I come up with something useful I'll post it here.
  8. On android I can play my game in Chrome and Firefox browsers, but on the stock browser there's no sound. Any ideas where I should start looking? I have my sounds encoded as ogg and mp3. Edit: the game in case someone is interested
  9. Thank you. Does that mean that the 'game' instance is not fully initialized when it's created (and returned), but is instead initializing itself at some (not very distant, since waiting for 0 ms is enough to let it complete) later time? Is that a javascript thing or a Phaser thing?
  10. This baffles me. If I do this game = new Phaser.Game(800, 400, Phaser.AUTO, '');console.log(game)console.log(game.add)the output in the browser console is this: >Phaser.Game null However, if I type "game.add" in the console the output is what I expected (ie >Phaser.GameObjectFactory). I ran into this because I wanted to create some shorthands in the start of the script for accessing common functions and making it more comprehensible (to me), like so: var factory = game.add; Please, what's going on?
  11. Hi, I wanted to create draggable buttons with some bitmaptext on them. I ended up with this: // the buttonvar button = this.game.add.button(x, y, "button", 0);button.input.enableDrag(false, false);// an intermediary group, just to be able to set the draggable 'button' as parentvar group = new Phaser.Group(this.game, button);// the text that i want to stick to the buttonvar text = new Phaser.BitmapText(this.game, 2, 2, "main-font", "text!!");group.add(text);Is there a more clever way to do this? For instance, the text has a 'parent' property that I can set directly, skipping the group. text.parent = button; I suppose that's from PIXI.GameObjectContainer. Presently, setting it as above works. Is there a safe way to use it, or some other way to use sprites/images/"gameobjectcontainers" as parents directly?
  12. Hi, how is the stopFullScreen() method meant to be used? I try this (modifying the fullscreen.js demo); function gofull() { game.scale.startFullScreen(); game.scale.stopFullScreen();}and get this: Uncaught TypeError: Object #<HTMLCanvasElement> has no method '' What's that about?
  13. Thanks for your reply! Storing the return value in tween like above doesn't change anything, however. The behavior is the same (In Chrome and Firefox) with this code: tween = game.add.tween(thing); tween = tween.to({x: 10, y: 300 }, 1000, Phaser.Easing.Bounce.Out); tween = tween.to({x: 200, y: 300 }, 1000); tween = tween.to({x: 200, y: 100 }, 1000); tween = tween.to({x: 10, y: 100 }, 1000);Anyway, am I missing something here? As I understand it, the .to() method doesn't return a new anything, it returns the 'tween' instance on which it was called, for chaining. So the var tween is referncing the same instance all along.
  14. Hi, I want to check whether a sequence of tweens has completed. However, the 'isRunning' flag only indicates whether the first step is 'running'. During step 2-4 in the example below it's set to false. It will be set to true again on the first step if the sequence loops. Is this how it's supposed to work? Is there a simple way to check whether the entire (non-looping) sequence has completed? var game = new Phaser.Game(640, 480, Phaser.CANVAS, '');var tween;var thing;var main_state = { create: function() { thing = {x: 10, y: 100 }; tween = game.add.tween(thing); tween.to({x: 10, y: 300 }, 1000, Phaser.Easing.Bounce.Out); tween.to({x: 200, y: 300 }, 1000); tween.to({x: 200, y: 100 }, 1000); tween.to({x: 10, y: 100 }, 1000); // tween.loop(); tween.start(); }, render: function() { game.debug.text('tween.isRunning: ' + tween.isRunning, thing.x, thing.y); }};game.state.add('main', main_state);game.state.start('main');
  15. @gonzalez32: Sorry for not answering, I've been away from the forum. Yes and no, the 'solution' that I found was using Firefox instead of Chrome when on Koding. (The code works fine in Chrome in general, it's just when using Koding, which really is quite slow, that this particular strangeness occurs). I've tried cloud9 as well, which works with both Firefox and Chrome, as long as you remeber to use public projects.
  16. Hi, I just spent a couple of hours figuring this out: var t;function moveSpriteUp (dt){ t + = dt; mySprite.y = 100 + t * 10;}That made the sprite rotate, not move. Why? Because t isn't initialized, t + dt is NaN, and setting sprite.x or sprite.y to NaN appearently messes with references so that some other sprite's rotation affects this sprite. I guess all kinds of strange behaivious could occur. This is how it shoud be: var t = 0; Piously using JSHint didn't help at all...
  17. Thanks for checking it out! The code loading to fast, that would be because the server is on a virtual machine perhaps? Anyway, I'll just use Firefox instead. Thanks!
  18. Hi, I'm trying to use the Koding cloud service for my Phaser stuff. Koding runs a virtual Ubuntu system, on which runs the apache web server. When I put my project files in the servers 'web' directory, I can load the index.html and various javascript files into my browser by navigating to the virtual host's external web adress. The images however are not loaded, and when I check the console in my browser I see the error message Phaser.Loader error loading file: cloud from URL /snel2/images/cloud.png phaser.min.js:9Resource interpreted as Image but transferred with MIME type text/html: "http://drphil.kd.io/snel2/images/hest.png". The link to the images adress on the server is working: I can open the image directly by clicking the link provided in the error message (But I guess that won't be the case when the virtual host is shut off, if anyone is curious). I know next to nothing about javascript or servers, so I post this in the hope that I'm making some simple mistake that can easily be spotted by someone who knows what he/she is doing. Thanks for reading!
  19. Here's something that took me really long to figure out: if you put your stuff in a 'private' project, you won't be able to load assets and such. Very nice cloud IDE, perfect for playing around with Phaser when you're not supposed to...
  20. Hi all, is there a more practical way to access the documentation than finding the relevant class in the drop-down menu? All suggestions greatly appreciated; even a page with all the links to classes listed would be useful, since it would be easier to search. What I'd really like to do is to connect to the docs from inside sublime text somehow. This is my first post. Thanks for all the effort put into Phaser!