ZRT Posted February 13, 2014 Share Posted February 13, 2014 Hey guys, I'm trying to recreate something I did in 1.1.3 to 1.1.5 but with states. Amongst few other issues, I encountered this one and hit a wall. I'm getting this error. I checked this thread but I don't think it's the same issue. Uncaught TypeError: Cannot read property 'baseTexture' of undefined Game.Play.prototype = { create: function() { // create player this.player = game.add.sprite(50, 100, 'player'); this.player.body.gravity.y = 7; this.player.outOfBoundsKill = false; // create obstacles this.ob = game.add.group(); this.ob.createMultiple(10, 100,'enemy'); this.ob.anchor.setTo(1,1); this.ob.body.velocity.x = -400; },Basically, I'm trying to recreate this, which works fine in 1.1.3 (without using states), although it might be little ugly chuck of code. function createObstacles() { // create bottom obstacles ob = obstaclesBottom.create(game.world.width, game.world.height, 'obstacle'); ob.anchor.setTo(1,1); ob.events.onOutOfBounds.add(obstaclesResetBottom); ob.events.onOutOfBounds.add(gameScore); ob.body.velocity.x = -400; // create top obstacles obt = obstaclesTop.create(game.world.width, 0, 'obstacle'); obt.events.onOutOfBounds.add(obstaclesResetTop) ob.events.onOutOfBounds.add(gameScore); obt.body.velocity.x = -400;}Thanks. Link to comment Share on other sites More sharing options...
hpcodecraft Posted February 13, 2014 Share Posted February 13, 2014 Have you tried using this.game instead of game? Link to comment Share on other sites More sharing options...
ZRT Posted February 13, 2014 Author Share Posted February 13, 2014 You mean like this.ob = this.game.add.group(); ? It's pretty much the same error. :S Link to comment Share on other sites More sharing options...
ZRT Posted February 14, 2014 Author Share Posted February 14, 2014 Seems I had the createMultiple wrong. Problem is solved with this code, after I reverted back to 1.1.3. this.obstacles = game.add.group(); this.ob = this.obstacles.create(this.game.world.width + Math.random() * 2000, 0, 'obstacle'); this.ob.body.velocity.x = -200; Link to comment Share on other sites More sharing options...
Recommended Posts