Artuki Posted March 13, 2018 Share Posted March 13, 2018 levers = this.physics.add.staticGroup(); levers.create(200, 160, 'lever', frame = 0, true, 0); console.log(lever.index) doesn't work in my overlap function. Apparently, index is undefined. I want to link a lever to a bridge so I was going to set both bridge and lever to have index 0 in their respective groups. Link to comment Share on other sites More sharing options...
rich Posted March 13, 2018 Share Posted March 13, 2018 Just curious, but why did you expect index to be defined in the first place? It's not a standard Group property, or a StaticGroup one either. You could add it if you wanted though. Link to comment Share on other sites More sharing options...
Artuki Posted March 13, 2018 Author Share Posted March 13, 2018 Because apparently phaser.group() in the documentation has 5 properties.... (x, y, key, frame, exists, index). @rich Link to comment Share on other sites More sharing options...
rich Posted March 13, 2018 Share Posted March 13, 2018 That's in Phaser 2. In v3 it's (x, y, key, frame, visible) Link to comment Share on other sites More sharing options...
Artuki Posted March 13, 2018 Author Share Posted March 13, 2018 51 minutes ago, rich said: That's in Phaser 2. In v3 it's (x, y, key, frame, visible) Oh okay, thanks. How do I do it then? @rich Link to comment Share on other sites More sharing options...
rich Posted March 13, 2018 Share Posted March 13, 2018 There's a few ways, but here's one: var partA = levers.create(x, y, key); var partB = levers.create(x, y, key); partA.setData('index', 0); partB.setData('index', 0); function collide (a, b) { if (a.getData('index') === b.getData('index')) { // do stuff } } Link to comment Share on other sites More sharing options...
Artuki Posted March 14, 2018 Author Share Posted March 14, 2018 Thanks @rich, I will try this later on today. I'm doing this to link a lever to a bridge. So, I was going to treat their group indexes as lookup lists in a sense. Link to comment Share on other sites More sharing options...
Recommended Posts