Videlais

Members
  • Content Count

    170
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Videlais

  1. @mamwalter: Most Phaser text writing doesn't work in CocoonJS. There is a patch, but it has not been accepted into Phaser (or even Pixi.js) yet. It won't work in WebGL mode, either.
  2. Since I can't tell from your description, let me ask the obvious: are you doing game.physics.arcade.collide() or other functions first in your game update? And, if you are using a tilemap, doing collision detection against it too? I do something like the following in my own very similar code. if(cursors.up.isDown && (this.body.onFloor() || this.body.touching.down)) { this.body.velocity.y = -350;}
  3. WebGL support is based, not on the browser itself, but the video hardware and drivers of the computer running it. This error might mean that the video drivers of that particular computer might need to be updated. Or maybe that support for WebGL isn't as good as it should be. (On some low end devices like most netbooks, WebGL won't work at all, for example.) The Non Power of Two (NPOT) issue has to do with how images are loaded on a low level. For WebGL mode, it is best to have images be 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, or 2048 pixels. Any other sized image is moved to the next highest power-of-two number, or sometimes not loaded at all depending on the software and hardware running it. As something to test, it might be worth switching to CANVAS mode and seeing if the same problems occur on that specific computer or others.
  4. As per Rich's suggestion, have you tried moving by a fixed amount? if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { sprite.body.x += 32;}If you set the sprite's anchor to be its middle, this will allow you to move 32 pixels from its position to the center, assuming your map is 32x32 tiles, of the next tile. sprite.anchor.setTo(0.5, 0.5);
  5. So, with just-- store.set('user', 'level01')--you aren't getting back 'level01' when using store.get('user')? This may read as obvious, but what does the following produce? console.log(store.get('user'))When tested right after, does it return the correct value? Something like the following, maybe. saveGame: function() { if(mapnumber === 1) { store.set('user', 'level01') } ... console.log('SAVED'); console.log(store.get('user')); },
  6. If you think about each printed color selection as its own little box, you can arrange the boxes on the screen using the first one as a reference and then move the rest as needed using its width and height. For example, say you wanted to print "Click on the Cat," as per your example. var chosenAnimal = "Cat"; //Stored name as a stringvar textStyle = { font: "65px Arial", fill: "#000000"};var text = game.add.text (400, 500,"Click on the ", textStyle); //Write the first text in blacktextStyle = { font: "65px Arial", fill: "#ff0000"}; //Change the fill color to 'red'var redText = game.add.text (400 + text.width, 500, chosenAnimal, textStyle); //Write the red text in the same x position + the width of the black text
  7. The thing to remember about localStorage is that key-value pairs stay that way until they are overwritten. If you are setting a value earlier in your code, or even from a previous session, that value will be there later. And it will continue existing until removed or overwritten at some later point too. Since you seem to be using store.js, have you tried calling store.clear()? When I was testing some code that was using localStorage in the past, I ran into a similar problem. Making sure I had cleared all the keys each time I was testing prevented a nasty error I was having where old values would show up future sessions. Something else to try is the following: store.forEach(function(key, val) { console.log(key, '==', val)})Just test that the values you expect to be there are actually there. Oh, and remember that localStorage is accessible from nearly all JavaScript running in the browser. It is often a good practice to add some type of identifier or name as part of the key. Just "user" can be useful in testing, but to make sure you aren't running into other keys called "user" from another source, adding something like your or the project's name before it can help. Reverse domain naming is very common.
  8. @JanneLeppanen: You aren't doing anything wrong. I was able to replicate that just now. It's now a confirmed issue.
  9. @tylerjhutchison: Phaser 2.0 will create a 'screencanvas' element correctly. That was fixed weeks ago. Without attaching the canvas element to the document.body via an appendChild call anyway, you aren't actually doing anything with it. Phaser will always use the canvas it creates internally. As for the parent element issue, that's because CocoonJS doesn't have a DOM in accelerated mode. Well... it does, but it's highly restricted. I guess I should probably spell it out clearer for people in the top post not to use anything there. The empty string is the correct method with CocoonJS. Yeah, I've discovered something similar. Any extra calls that do not depend on images will cause them to appear afterwards. For you, that's the call to Phaser.Circle (and its internal drawing) and for others it is the use of an extra call to "game.add.image(0,0,'')". That's the problem I've been trying to track down. I'm fairly certain it has to do with the tweening issue too, that images aren't working as they should.
  10. @momothemonster: Yeah, that's been the problem. It doesn't work for anyone when using the accelerated mode in CocoonJS with Phaser.CANVAS right now. (I'm not interested in WebView mode, as that is platform-dependent.) I'm pretty sure it's a problem that has its roots in changes to Phaser as a result of merging with the 1.5 branch of the Pixi.js code. Just haven't been able to narrow it down yet.
  11. Weird. If you don't mind, then, could you try that above code with the image loading and displaying? Substitute in any image you want. It hasn't worked for me all day and I've been trying to track down the reason. Run it using the accelerated mode in CocoonJS and let me know if anything appears at all.
  12. @momothemonster: But only in WebView mode, right?
  13. @momothemonster: It might not be the tween but the image itself. For example, the following code will not display anything currently. var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {preload: preload, create: create}); function preload() { game.load.image('diamond', 'diamond.png'); } function create() { game.add.sprite(150, 150, 'diamond');}So, it's probably that the images aren't being loaded correctly somehow. (I'm pretty sure now, after hours of testing, Pixi.js is to blame.)
  14. @rich: Hmm. Well, it looks like images might be broken in CocoonJS for some reason. The following code doesn't display anything. var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {preload: preload, create: create});function preload() { game.load.image('diamond', 'diamond.png');}function create() { game.add.image(150, 150, 'diamond');}It's not strictly something to do with 2.0.1, I know, but I hadn't moved over to testing Phaser 2.0 proper yet. (The 1.2 'dev' branch was, about a week ago, working fine for me in CocoonJS though.) I'm looking into it today.
  15. @rich: Has anything been changed with regard to loading or handling images in 2.0 or 2.0.1? I'm getting reports of images disappearing in CocoonJS in Accelerated mode with Phaser.CANVAS. The current fix, which I'm trying to figure out, is to add an extra "game.add.image(0,0,'')" to the code. For example, to make the Diamond Burst emitter example work with Phaser 2.0.1, that extra "var fake..." line needs to be added. var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {preload: preload, create: create});var p; function preload() { game.load.image('diamond', 'diamond.png'); } function create() { game.stage.backgroundColor = '#337799'; p = game.add.emitter(game.world.centerX, 200, 200); p.makeParticles('diamond'); p.start(false, 5000, 20); var fake = game.add.image(0, 0, ''); }
  16. @ freaker: I haven't worked out a fix yet, but the problem isn't in emitter. It's something to do with how images are loaded and it affects not only the emitter functionality, but everything that uses images at the moment. If you haven't already seen this topic, it is where I have been documenting the various issues and fixes for Phaser with CocoonJS. This image problem is something that has appeared with the 2.0 change.
  17. @iShellz: CocoonJS doesn't have any XML support when run in Accelerated mode. If you absolutely need XML support, you can add it back in via this library I've written. If it is loaded before Phaser is, it will act in place of XML support for CocoonJS. (I've confirmed it works with BitmapFonts in Phaser, but is still a work-in-progress for other XML needs.)
  18. @mamwalter: I've confirmed this image issue. As you wrote, it not only affects buttons, but everything that relies on them. (It's showing up in another, emitter, issue too.) I've started investigating this and will add it to the known issues list until a fix is in place. In the meantime, if you solve this this, please let me know.
  19. @freaker: I commented on your other post too, but I'll write the same here: I'm going to look into this. There have been some reports of problems with Phaser 2.0 and CocoonJS that I'll be trying to figure out today. However, something I'm curious about having read both posts now is which mode you are using for this testing. Are you using WebView or Accelerated mode in CocoonJS? There are separate issues for each and it could be something completely unrelated to CocoonJS if you are having problems while using the WebView mode. Something else to remember is that, with Accelerated Mode, there isn't much of a DOM. In other words, you need to use an empty string for the parent element. Something like the following: var game = new Phaser.Game(800, 600, Phaser.WEBGL, '', { preload: preload, create: create });And, as I commented on the other topic, WebGL mode is broken in a number of ways in CocoonJS right now. There is a fix coming, but it will be when they release their next version. Edit: I just tried your (the example) Canvas code and got the same response. I'm going to move this to a known issue in just a few minutes.
  20. @freaker: WebGL mode in CocoonJS is actually broken in a number of ways right now. This has been documented in a number of places and, as of some recent conversations I've had with the CocoonJS developers, there should be a fix coming in the next version. It's not recommended to use WebGL mode with Phaser right now, though. I saw your other post about the particles when using Canvas in CocoonJS. I'm going to look into that today and see if it is related to another recent problem I've been hearing about too. As for down-scaling, I agree with @spartanatreyu. It's generally not a good idea. Scaling up isn't too bad using the following code: var width = window.innerWidth * window.devicePixelRatio;var height = window.innerHeight * window.devicePixelRatio;It will calculate using devicePixelRatio (for Retina screens with higher pixel ratios) and multiply the number with the width and height of the screen as reported by CocoonJS. That way, the app will look the same, scaling up as needed, on different devices and hardware.
  21. @CaueCR: Sorry for the extended delay in replying back. I saw your code right away -- thanks for posting it -- but wanted to test some things myself. I also had to wait to hear back from an expert I know on this. The answer to your original question is quite complicated, it turns out. To get videos working in CocoonJS in its 'accelerated' mode, you need to use the "App_ForWebView" extension to create a WebView instance on top of 'accelerated' one. From there, you need to test which formats the particular platform can use, load the correct file, and then signal to the 'accelerated' view that it is ready. Maintaining a bridge of sorts across the two different views, a video can be played in one, the WebView, and controlled from another. It's not at all a clean approach and definitely much more trouble than it is worth, believe me. And, to be honest, for those wanting video support and who don't plan to the use the 'accelerated' mode, the WebView mode should work fine on most platforms anyway. There's little need to mix the two for this. Oh, and I should probably note that, outside of CocoonJS' 'accelerated' mode, most browsers support the video element as an argument to the canvas drawImage function. Assuming the element exists and its corresponding video has already been loaded by the browser, you can do the following: ctx.drawImage(videoElement, 0, 0);It will draw the current frame of the video element to the canvas and, when run via its own play function, allow people to play the audio from the file while also showing the video on the canvas as if it was any other image.
  22. @iShellz: Are you stating the text is not updating or that, after changing the name of the font, the text does not reflect this change? If it is the first, that could be a major problem. If it is the second, I'm pretty sure you can't rename fonts during execution without a call to the loading functions.
  23. To sort of answer your original question, there is PhoneGap, as you mentioned, Cordova, which PhoneGap is based on, Ejecta, for those projects targeting only iOS, Titanium, which has its own set of APIs, Game Closure, CrossWalk, and, of course, CocoonJS (which I've personally spent a great deal of time working with and submitting patches to Phaser for over the last several weeks). If you are just looking for WebGL, CocoonJS might not be what you want just now. There are a number of known issues with the current version, including some that pertain to basics like writing text in WebGL mode. (And it also doesn't have WebAudio either, by the way. At least, not in its 'accelerated' mode currently.) Depending on how hardcore you want to go about it, you could even compile your own version of Chromium from its source. Many of these wrapper software projects are, at their root, variations of Chromium with additions or special hacks here and there. I do know some people are rolling their own versions now too.
  24. @mamwalter: Does everything work outside of CocoonJS? When run on a Desktop browser like Chrome or Firefox, does everything appear correctly? Are there differences between the WebView and the Accelerated View with your code in CocoonJS? Does one work better than the other, or are the problems the same in each? If you can, it is worth trying different combinations of Desktop or mobile browsers before using CocoonJS. Knowing if something works on a mobile platform's default browser, for example, will often let you know if the WebView mode will work for you (as it uses the same software). Are you using the Custom Launcher or code run through the cloud compiler? If you can, always test using the Custom Launcher before using the cloud compiler. You get access to the console and can often diagnose problems faster. Oftentimes, this will let you know if there are loading problems with resources like images or other files. Finally, try debugging your code with some calls to console.log. I know I often make small typing errors in my code. I've often found it can helpful to step through some small section line-by-line just to double check values are being set correctly or certain calculations are being made as they should be. Maybe that will help you too with this.
  25. @programlocura: While it is true CocoonJS doesn't support PHP (it is just a browser itself), I don't think that is particularly the issue here. If you are getting cross-domain issues, it is most likely because you are breaking a security rule about accessing resources outside of your domain. If you want a CocoonJS app to have access to data provided from a PHP script, that file needs to be publicly accessible. Just like any other browser, CocoonJS can make a XHR object and GET or POST data. What you might need to do is have the PHP script call this external service either before, as part of some type of regular polling, or right after as a result of an incoming connection just like you would for a web page. If you are getting the file contents of a PHP script, it is probably because the server is not running it, but is sending it as plain text instead. That's not a problem with Phaser or CocoonJS but probably with the server settings themselves.