Search the Community
Showing results for tags 'phaser cache'.
-
Hi All, I am new to phaser and going through it and i came across state in phaser. I need to know if i can maintain my pervious state active in the background so that i can be able to handle assets loading in the active without getting caught in the Phaser.cache.getImage error. Thanks in advance,
-
I'd like to manually add a sprite sheet to Phaser's cache. (In case you're asking why, I'm tinting and manipulating the bitmapdata from one generic set rather than manually making the number I need.) But, I've not been able to do this - I have manually added my manipulated bitmapdata - and I'm blitting my sprite. This works fine, but is not very optimised (or doesn't play well on old devices.) I'm hoping that using Phaser's native sprite functionality might improve this. Can anyone guide me as to add a sprite sheet - I think where I'm falling over is the framedata, but it's not 100% clear (to me at least) from the docs how to do this. Thanks!
-
I'm just playing about with some bitmapdata and have hit a bit of a wall. game.cache.getBitmapData('ball'+team);// returns null game.cache.getimage('ball'+team);//returns the image game.cache.checkBinaryKey('ball'+team);// evaluates false I'm guessing the bitmapdata is returning null because the key isn't there - but the image definitely is there and works... Where am I going wrong?
-
Hi Guys, this is my first post here and I hope that I have been putting it under the right category So I am working with AngularJs to add some menus before my game starts. I am also using EZGUI to add some ingame menus. I really need the Angular part that I have already built cause I am doing more complex things like user authentication in there, which I don't wanna do in Phaser. To my problem: I am trying to switch views between my Angular part and the Phaser Game. I got something working that actually lets me change in and out of my game without any lags, but gives me the following error, when I loaded the game once, switched back into my Angular part and then switch back into my game: Uncaught TypeError: Cannot read property 'cache' of null Important to mention here is probably how I go about switching my views. In my game controller that loads my game into my div (canvas), I wrote a little function that lets me load scripts asynchronously and appends them to the head, when I switch out of my game into my Angular menu controller. I remove that script again from the DOM to be able to reload it later again. The script is fairly tiny so it doesn't take up much loading time. It only contains my game setup: (function() { var game = new Phaser.Game(screen.width, screen.height, Phaser.CANVAS, 'gameCanvas'); // add our game states game.state.add('boot', MMM.Boot); game.state.add('preload', MMM.Preload); game.state.add('main-game', MMM.MainGame); // start with the booting state game.state.start('boot');})(); I am also clearing the cache with this.game.cache.destroy(); and I am destroying the game with this.game.destroy(); in my main game file before I switch into the Angular menu controller again. I am basically trying to remove the game components completely right before I switch into my menu controller, because the user might reside there for a while (chatting, looking through the store, setting up a new password, etc...) and I don't want any game related components running in the back during that time. I have been searching through quite some forum articles trying to find what I am looking for. I read somewhere that Phaser attaches additional eventHandlers to the window object, which aren't removed when you call this.game.destroy() I hope somebody out there tried something similar and can help me out on this one. I am quite stuck here :S Any help is appreciated!
-
Hi Guys, I am new to this community and this is actually my second post, but my first one didn't appear. So I hope I am not posting my question twice. If it does appear, my apologies! Anyhow, I am pretty stuck on a problem. I found a dirty work around, which I would really like to get rid of though. I think the problem is a little bit more complex and I don't know if I am making the right assumptions considering my solution, but I hope somebody tried the same with a different solution approach. So here we go: Basically, I am trying to switch in and out of my game, over states with Angular. I set up a simple controller, which is been given my <div> container in a template, which I add my game into when I switch to that route. The way I load my game into the container when I hit the state/route is that I wrote my own lazy loading function that loads my game setup: (function() { var game = new Phaser.Game(screen.width, screen.height, Phaser.CANVAS, 'gameCanvas'); // add our game states game.state.add('boot', MMM.Boot); game.state.add('preload', MMM.Preload); game.state.add('main-game', MMM.MainGame); // start with the booting state game.state.start('boot');})(); When I exit my game and return to my menu controller, I remove my script again from the <head> and destroy the phaser game and I try to clear the cache with this.game.cache.destroy() If I want to enter my game again I just load the above script again with my lazy load function. It enters my game just fine, but i get the following error: Uncaught TypeError: Cannot read property 'cache' of null I tried reloading all of my game related scripts including my preload script, but the error stays the same.The assumption that I made was that the game is not actually completely destroyed and thus has some remains which cause errors. My work around is to do a $window.location.reload(false); and load everything again from cache. Works without any errors and loads quickly, too, but I really don't like how I am going about this. Any recommendations? Thanks in advance!
- 1 reply
-
- Phaser Cache
- Phaser Object
-
(and 1 more)
Tagged with: