Search the Community
Showing results for tags 'outOfBoundKill'.
-
Hi, I'm some newbie programmer that need a little help in his starts. Now i have three questions to ask you. First. I've find an examples of sprite garbageCollector, but its work only in older versions (i test it on 1.1.5). How can i fix it? Here is code: var game = new Phaser.Game(800, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });var clouds;var cloud_dummy;function preload() { game.load.image('mario_cloud', 'mario_cloud.png');}function create() { clouds = game.add.group(); clouds.enableBody = true; clouds.createMultiple( 10, 'mario_cloud'); timer_shit = game.time.events.loop(1500, add_cloud, this);}function update() {}function add_cloud() { cloud_dummy = clouds.getFirstDead(); cloud_dummy.reset(800, 100); cloud_dummy.body.velocity.x -= 150; cloud_dummy.body.immovable = true; cloud_dummy.outOfBoundsKill = true;}Error message: Phaser v2.0.3 - WebGL - WebAudio http://phaser.io ♥♥♥ phaser.min.js:8 Uncaught TypeError: Cannot read property 'reset' of null (index):34 add_cloud (index):34 b.Timer.update phaser.min.js:12 b.Time.update phaser.min.js:12 b.Game.update phaser.min.js:8 b.RequestAnimationFrame.updateRAF phaser.min.js:11 window.requestAnimationFrame.forceSetTimeOut._onLoop phaser.min.js:11 Second question: I've some trouble with accessing elements of group. In example that u can see above, we have group named clouds and a cycle that add cloud_dummy elements to it. For example i have 10 elements on the screen, and i wanna access 3rd element of group to run other animation.run(). How can i do this trick? Third question: I've 2 browsers on my net-book, Chrome and Firefox. In Firefox my games(like example above) lag so hard, but Chrome give me around 60fps and have a little lagspikes that drop fps to 50. Phaser.CANVAS works better in Firefox and Phaser.WEBGL works better in chrome. How can i optimize my games to work better in both browsers? EDIT 03.05.2014: I've find a reason why my garbageCollector won't work. I forgot to check world bound for every sprite... Code shoul look like that: function add_cloud() { cloud_dummy = clouds.getFirstDead(); cloud_dummy.reset(800, 100); cloud_dummy.body.velocity.x -= 150; cloud_dummy.body.immovable = true; cloud_dummy.checkWorldBounds = true; cloud_dummy.outOfBoundsKill = true;}
- 1 reply
-
- outOfBoundKill
- group element
-
(and 2 more)
Tagged with: