Monster9800 Posted July 21, 2017 Share Posted July 21, 2017 Hi, I've got a problem with my game project. I creted archer, he shoting arrows, but have problem with flying rotation (screen). Arrow still flying straight (left), I would like to get right side effect (fly to up/down at an angle as in live). Any idea ? Sorry for my english, it's not my native language Link to comment Share on other sites More sharing options...
samme Posted July 22, 2017 Share Posted July 22, 2017 arrow.rotation = arrow.body.angle; Link to comment Share on other sites More sharing options...
Monster9800 Posted July 22, 2017 Author Share Posted July 22, 2017 Thanks for answer but it's not help me. I add lane here: function firearrow() { if(nextShot>game.time.now){ reloadtxt.visible = true; return; } else{ var arrow = arrows.getFirstExists(false); if (arrow) { arrow.reset(550, 410); arrow.body.velocity.x = 800; arrow.rotation = arrow.body.angle; game.physics.arcade.moveToPointer(arrow, 480); } } nextShot = game.time.now + 1000; } Effect: First few arrows fly without rotation (why ?), then there is rotation, but in the canvas: rotation is down and it has just been fired. // Edit: My code group create arrows = game.add.group(); arrows.enableBody = true; arrows.physicsBodyType = Phaser.Physics.ARCADE; arrows.createMultiple(20, 'arrow'); arrows.callAll('events.onOutOfBounds.add', 'events.onOutOfBounds', resetarrow); arrows.callAll('anchor.setTo', 'anchor', 0.5, 1.0); arrows.setAll('checkWorldBounds', true); Link to comment Share on other sites More sharing options...
samme Posted July 22, 2017 Share Posted July 22, 2017 It needs to be in update, like function update () { arrows.forEachAlive(function (arrow) { arrow.rotation = arrow.body.angle; }, this); } Monster9800 1 Link to comment Share on other sites More sharing options...
Monster9800 Posted July 22, 2017 Author Share Posted July 22, 2017 I thought to put this in an update but I did not think about forEachAlive. Thanks you so much My problem solved, close the topic, please. samme 1 Link to comment Share on other sites More sharing options...
Recommended Posts