Jump to content

Search the Community

Showing results for tags 'nested'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 4 results

  1. I have two groups of sprites, one containing trees, and another one containing characters. I want to sort them with the group.sort() function, but in order to do that I would need to put them in other, bigger group. However, I can't do that with the approach taken in the example of "sub groups", because when I do it that way, the _container has other containers as its children, instead of the actual sprites. What is the best/easiest way to accomplish this, without losing the flexibility of having separate groups for trees and characters?
  2. Hi there. I have a noob question... How I can update bounds of nested sprites? For example: I have a sprite levelSprite = this.game.add.sprite(0, 0); //now width and height - 32x32This sprite has two childs levelNum1 = this.game.add.sprite(0, 0, 'game_assets_4');levelNum1.frameName = "gm_level_number_0001.png";levelNum2 = this.game.add.sprite(100, 100, 'game_assets_4');levelNum2.frameName = "gm_level_number_0002.png";levelSprite.addChild(levelNum1);levelSprite.addChild(levelNum2); // now width and height still 32x32... why? I use phaser v. 2.4.3 Would you be so kind to help me please...
  3. Hi All, I've searched this forum and the internet in general regarding my issue but can't find a solution. I'm adding one sprite (beam as in tractor beam) as a child to another sprite (saucer, as in flying saucer) and then adding this composite sprite to a group (flyingSaucerGroup). I add x number of these composite sprites (saucer and accompanying child beam) to this group in a for loop. I have another group of sprites (squirrelGroup) which contain the squirrels that are being abducted by the flying saucers. In the update function I have this line of code : this.physics.arcade.overlap( this.squirrelGroup, this.flyingSaucerGroup, this.collisionAbduct, null, this);When a beam from a flying saucer overlaps a squirrel, I expected that the callback function (this.collisionAbduct) would be triggered but its not. I know the problem has something to do with how I'm attaching these sprites to the group. I assumed that since the child beam was attached to the saucer parent which was added to the flying Saucer group that all sprites therein would be considered part of the flyingSaucerGroup that is being checked for collisions. Here is the callback code so you can see there is nothing funky going on there: collisionAbduct: function(s, { var txt = this.add.text(this.world.centerX, this.world.centerY,"squirrel killed" ); s.kill(); },Please take a look at the actual pertinent code and screen shot below. Thank you in advance for any help! Best, Michael
  4. Hello phaser community, I observed some kind of misbehaviour with group nesting. It seems that the reference for the nested group is lost and PIXI.DisplayObjectContainer is exposed instead. Look at the following Testcode. There is a sprite in a group which is added itself to another group. When I try to retrieve the nested group with #getAt it returns a PIXI.DisplayObjectContainer and not the Phaser.Group object. I think this is not an expected behaviour ? I digged that deep because my initial problem was (and still is) that #countDead is not working with nested group items because of this behaviour (It's not iterating over the nested group elements but over the corresponding PIXI Containers., with the lack of the alive attribute). I couldn't find a back reference from DisplayObjectContainer to the Phaser.Group object. With this I could have build a workaround but I couldn't find anything to map PIXI objects to Phaser objects. //create a base group to start withbaseGroup = @game.add.group()//add another nested group (to create the misbehaviour)nestedGroup = @game.add.group()baseGroup.add(nestedGroup)//now create a sprite to have a non-group type to addsprite = @game.add.sprite(0, 0, 'cap');//add it to the nested groupnestedGroup.add(sprite)//Now let's do some testing://output: sprite should be found in child group: expected: (true) is trueconsole.log 'sprite should be found in child group: expected: (true) is', nestedGroup.getAt(0) == sprite//output: base group should container the nested group: expected: (true) is false console.log 'base group should container the nested group: expected: (true) is', baseGroup.getAt(0) == nestedGroup //output: group#getAt should not expose PIXI Container: expected: (Phaser.Group) is (PIXI.DisplayObjectContainer)console.log 'group#getAt should not expose PIXI Container: expected: (Phaser.Group) is', baseGroup.getAt(0) //Test with countDead which uses group#iterate//First of all: set sprite dead. This is only a flag and should be reflected in method group#countDead.sprite.alive = false//default ist already true, for the sake of consistency.nestedGroup.alive = true//Sprite is DEAD, nestedGroup is ALIVE. Test it://output: our sprite is dead, so this should be 1 is 1 console.log 'our sprite is dead, so this should be 1 is', nestedGroup.countDead()//output: our nested group is alive should be 0 is 1 console.log 'our nested group is alive should be 0 is', baseGroup.countDead()I know that there was an update in a commit between 1.1.3 and 1.1.4 (see this commit). It seems to be related, because of the following selected code line. When nesting a group it's unerlaying PIXI object is added. But the reference to the Phaser.Group is lost at this point isn't it ? So all following calls to group#getAt(index) is return a PIX object and not the Phaser.Group object. add: function (child) { if (child.group !== this) { if (child.type && child.type === Phaser.GROUP) { child.group = this; // Do we lose the reference to the Phaser.Group itself here ? this._container.addChild(child._container); (Source: github) My workaround for now is to maintain a own list/array of group items. It would be great to depend on Phaser's own display list. Thanks for reading. Regards George
×
×
  • Create New...