hellspawn_bg

Members
  • Content Count

    50
  • Joined

  • Last visited

About hellspawn_bg

  • Rank
    Advanced Member
  • Birthday 08/01/1985

Profile Information

  • Gender
    Male
  • Location
    Sofia, Bulgaria

Recent Profile Visitors

761 profile views
  1. Upon game over I am trying to render the screen on a texture which would be passed on the next state as a background. Sofar I have implemented this, but I end up with a black screen instead. In the game state I do this: this.texture= new Phaser.RenderTexture(this.game, this.game.width, this.game.height);this.texture.renderXY(this.game.stage, 0, 0);In the new state I set the texture as a background: this.background = new Phaser.Sprite(this.game, 0, 0, this.texture);Any ideas? Thanks
  2. I am wondering how to implement the stage cleanup when switching between 'Game' and 'GameOver' stage. Should I simply put this = null in the shutdown function or should I nullify all the objects created in the stage. I have alot of objects and vars created in my stage and I want to avoid memory leaks when switching stages. Game = function(game) { .... //hell of alot vars defined here};Game.prototype = { create: function() { this.obj1 = new Obj1(); this.obj2 = new Obj2(); .... }, gameOver: function() { // Switch to game over stage this.stage.start('GameOver'); }, shutdown: function() { }};
  3. I get this error upon boot state start Uncaught TypeError: undefined is not a function phaser-no-physics.js:26236 Phaser.Input phaser-no-physics.js:26236 Phaser.Game.boot phaser-no-physics.js:25389 Phaser.Device._readyCheck phaser-no-physics.js:44600
  4. I am not sure that you can set group width. The group is used to simply logically group objects having the same behaviour.
  5. Recently I have been following an ongoing discussion regarding mobile performance and efficiency. One of the recommendations that caught my eye was to avoid classes and prototyping altogether because they can slow down the performance significantly. So far I have structured my code by creating separate class objects in different files by using prototypes. class = function () {}class.prototype.myMethod1 = function () { console.log('myMethod');}class.prototype.myMethod2 = function () { console.log('myMethod2');}In this regard, I am wondering what is the recommended and most efficient way to structure your code? Perhaps the more experienced users can share something from their bag of tricks. Thanks
  6. Thank you very much SolarJS. Your sample was really helpful, but what about inheritance? In the first case we can inherit Phaser.Sprite like this: BallObject = function(game, x, y) { Phaser.Sprite.call(this, game, x, y, 'basketball');};BallObject.prototype = Object.create(Phaser.Sprite.prototype);BallObject.prototype.constructor = BallObject;What would be the analog in the second method? Thank you once again.
  7. @defic. My code also looks like that and I am interested how to go with the pre-cached functions. @SolarJS: Perhaps you can show an example, based on the code above? Thanks
  8. Strangely though, the physics arcade body has allowRotation property which returns true in my case.
  9. Hey guys, I have noticed that when I rotate my sprite by altering the angle, the physical body of the sprite doesn't get rotated. Any ideas why? Here is my code: preload: function() { this.starShip = this.add.sprite(this.world.centerX, this.world.centerY, 'starShip'); this.starShip.anchor.setTo(0.5, 0.5); // Needed for the collision detection this.game.physics.arcade.enable(this.starShip); }, update: function() { // Player turns left if (this.cursors.left.isDown) { this.starShip.angle -= 3; } // Player turns right else if (this.cursors.right.isDown) { this.starShip.angle += 3; } }, render: function() { this.game.debug.body(this.starShip); }And here is the result: Thanks
  10. Got it working. Was using load.atlas instead of load.atlasJSONHash.
  11. I recently came across this warning, while trying to pack my images into a single texture atlas. I have prepared the atlas with TexturePacker using JSON Hash. For the purpose of the demo I have created a texture with 2 images inside. I have set the texture size to power of 2. The content of the JSON file is: {"frames": {"cat.png":{"frame": {"x":2,"y":68,"w":50,"h":50},"rotated": false,"trimmed": false,"spriteSourceSize": {"x":0,"y":0,"w":50,"h":50},"sourceSize": {"w":50,"h":50},"pivot": {"x":0.5,"y":0.5}},"dog.png":{"frame": {"x":2,"y":2,"w":80,"h":64},"rotated": false,"trimmed": false,"spriteSourceSize": {"x":0,"y":0,"w":80,"h":64},"sourceSize": {"w":80,"h":64},"pivot": {"x":0.5,"y":0.5}}},"meta": {"app": "http://www.codeandweb.com/texturepacker","version": "1.0","image": "gameContent.png","format": "RGBA8888","size": {"w":128,"h":128},"scale": "1","smartupdate": "$TexturePacker:SmartUpdate:4d5d08212283de860125419268743cc3:0b7ce17362320bea73869f2c1a9da2bb:e88dd6268be3835132a863977762ea7c$"}}In my pre-loader I am loading the atlas using: this.load.atlas('gameContent', 'assets/images/test/gameContent.png', 'assets/images/test/gameContent.json');In my create function, I am loading the cat only: this.cat = this.game.add.sprite(0, 0, 'gameContent', 'cat.png');Upon startup I am seeing this warning in the console. Cannot set frameName: cat.png And instead of loading only the cat from the atlas, it loads the hole gameContent.png. Am I missing something here? Thanks
  12. Thanks, Lewster, I will stick with the first proposal. Thank you, Rudy
  13. Thanks, Lewster. Will the addition of a new timer in the callback affect the performance anyhow (if the drop is happening every couple of seconds) and should I worry about garbage collection?
  14. I am trying to implement some random events happening in my game. For example I want to drop an item on every 5 to 10 seconds. In phaser there is an easy way to create loop events, but they all loop at a certain time. What I am doing so far to achieve this is to add a delay on the event in the timer callback. Is there a smart way to create create events looping in some time range? // Initialize drop timervar cooldown = this.game.rnd.realInRange(this.coolMin, this.coolMax);this.dropTimer = this.game.time.create(false);this.dropEvent = this.dropTimer.loop(Phaser.Timer.SECOND * cooldown, this.dropItem, this);this.dropTimer.start();// dropItem function Grabbable.prototype.dropItem= function() { // Do something // Reset timer var cooldown = this.game.rnd.realInRange(this.coolMin, this.coolMax); this.dropEvent.delay = Phaser.Timer.SECOND * cooldown;};