dthrasher90 Posted May 10, 2017 Share Posted May 10, 2017 is it possible to pass a sprite with an physics system from one function to another? Like i have spriteA with arcade physics enabled in file jsfile1.js. and I have a state in gamestate.js. How can I send that sprite with an active physics engine to the update function of gamestate.js Link to comment Share on other sites More sharing options...
dthrasher90 Posted May 10, 2017 Author Share Posted May 10, 2017 update: function(rg, dt1){ game.physics.arcade.collide(rg, dt1, this); //end update brackt }, // the below is in a separate file, called ona button press. function runPlayMiddle(){ playCount = +playCount; playCount += 1; console.log("playcount = ", playCount); if(playCount == 1){ var ct = game.add.sprite(220, 220, 'ct'); ct.scale.setTo(0.03); // this.game.physics.arcade.enable(ct, Phaser.Physics.ARCADE); } else{ var ct = game.add.sprite(newBallSpotx, 220, 'ct'); ct.scale.setTo(0.03); // this.game.physics.arcade.enable(ct, Phaser.Physics.ARCADE); } runningPlaysDownChecker(); Base43Defense(ct); var QBx = ct.x - 20; var QBy = ct.y; var qb = this.game.add.sprite(QBx, QBy, 'qb'); qb.scale.setTo(0.02); var RB1x = ct.x -70; var RB1y = ct.y; var rb1 = this.game.add.sprite(RB1x, RB1y, 'rb1'); rb1.scale.setTo(0.02); var spriteTextRB1 = game.add.text(RB1x, RB1y, 'RB1', { font: '9px Press Start 2P' }); var RGx = ct.x; var RGy = ct.y + 20; var rg = this.game.add.sprite(RGx, RGy, 'rg'); rg.scale.setTo(0.03); var spriteTextRG = game.add.text(RGx, RGy, 'RG', { font: '9px Press Start 2P' }); this.game.physics.arcade.enable(rg, Phaser.Physics.ARCADE); var RTx = ct.x; var RTy = rg.y + 20; var rt = this.game.add.sprite(RTx, RTy, 'rt'); rt.scale.setTo(0.03); var spriteTextRT = game.add.text(RTx, RTy, 'RT', { font: '9px Press Start 2P' }); this.game.physics.arcade.enable(rt, Phaser.Physics.ARCADE); var LGx = ct.x; var LGy = ct.y - 20; var lg = this.game.add.sprite(LGx, LGy, 'lg'); lg.scale.setTo(0.03); var spriteTextLG = game.add.text(LGx, LGy, 'LG', { font: '9px Press Start 2P' }); this.game.physics.arcade.enable(lg, Phaser.Physics.ARCADE); lg.body.velocity.x = + 25; var LTx = ct.x; Link to comment Share on other sites More sharing options...
dthrasher90 Posted May 10, 2017 Author Share Posted May 10, 2017 The velocities in the above example work, but i cannot get it to update Link to comment Share on other sites More sharing options...
Recommended Posts