vmars316 Posted January 25, 2016 Share Posted January 25, 2016 Hello I am getting a green shadow on my *sprite .png s . And when I kill a sprite , the green shadow is still there . I think it has something to do with BoundingBox , but I don't see it yet . Thanks for your help ! see below or here: http://liesandcowpies.com/testMe/vm-phaser/vm-vertical-collision-Web.html Quote var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'vm-vertical-collision', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('truth02', 'truth02.png'); game.load.image('cowpie', 'cowpie.png'); game.load.image('bullet', 'cowpie.png'); game.load.image('thrower', 'thrower.png'); // game.load.image('bullet', 'C:/Phaser/phaser-2.4.4/DownloadExamples/phaser-examples-master/examples/assets/games/asteroids/bullets.png'); } var truth02sprite; var cowpieSprite; var throwerSprite; var cursors; var bullet; var bullets; var fireRate = 500; var nextFire = 0; var bulletTime = 0; function create() { game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = '#2d2d2d'; truth02sprite = game.add.sprite(300, 50, 'truth02'); truth02sprite.name = 'truth02'; game.physics.enable(truth02sprite, Phaser.Physics.ARCADE); // truth02.body.velocity.y = 100; truth02sprite.body.immovable = true; // See the offset bounding box for another example. // truth02sprite.body.setSize(64, 64, 0, 0); cowpieSprite = game.add.sprite(300, game.height -175 , 'cowpie'); cowpieSprite.name = 'cowpie'; game.physics.enable(cowpieSprite, Phaser.Physics.ARCADE); cowpieSprite.body.velocity.y = -300; cowpieSprite.body.acceleration.y = -300; // Our cowpie bullets bullets = game.add.group(); bullets.enableBody = true; game.physics.enable(bullets, Phaser.Physics.ARCADE); // All 40 of them bullets.createMultiple(10, 'bullet'); // bullet becomes bullets bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 0.5); // bullets.body.velocity.y = -300; // bullets.body.acceleration.y = -300; // throwerSprite = game.add.sprite(game.width / 2, game.height -125, 'thrower'); throwerSprite = game.add.sprite(300, game.height -125, 'thrower'); throwerSprite.name = 'thrower'; game.physics.enable(throwerSprite, Phaser.Physics.ARCADE); // throwerSprite.body.velocity.y = -300; // throwerSprite.body.acceleration.y = -300; cursors = game.input.keyboard.createCursorKeys(); } //function update() { // game.physics.arcade.collide(cowpieSprite, truth02sprite, collisionHandler, null, this); //} function update() { game.physics.arcade.collide(cowpieSprite, truth02sprite, collisionHandler, null, this); // game.physics.arcade.collide(bullet, truth02sprite, collisionHandler, null, this); // if (cursors.up.isDown) if (cursors.up.isDown) { fireBullet(); } /* else { sprite.body.acceleration.set(0); } if (cursors.left.isDown) { sprite.body.angularVelocity = -300; } else if (cursors.right.isDown) { sprite.body.angularVelocity = 300; } else { sprite.body.angularVelocity = 0; } screenWrap(truth02sprite); bullets.forEachExists(screenWrap, this); */ } function collisionHandler (obj1, obj2) { game.stage.backgroundColor = '#992d2d'; cowpieSprite.body.velocity.y.stop; obj1.kill(); // truth02sprite.body.invisible = true; } function fireBullet () { if (game.time.now > nextFire) { nextFire = game.time.now + fireRate; bullet = bullets.getFirstExists(false); if (bullet) { bullet.reset(throwerSprite.body.x + 16, throwerSprite.body.y + 16); bullet.lifespan = 2000; bullet.body.velocity.y = -300; bullet.body.acceleration.y = -300; // bulletTime = game.time.now + 50; } } } function render() { game.debug.body(truth02sprite); game.debug.body(cowpieSprite); game.debug.body(bullets); } Link to comment Share on other sites More sharing options...
swemaniac Posted January 25, 2016 Share Posted January 25, 2016 game.debug.body(truth02sprite); This Link to comment Share on other sites More sharing options...
vmars316 Posted January 25, 2016 Author Share Posted January 25, 2016 Yes , that did it Thanks ! Link to comment Share on other sites More sharing options...
cdelstad Posted January 26, 2016 Share Posted January 26, 2016 Using the debug puts a green border around your sprites so you can tell real vs. apparent size. Link to comment Share on other sites More sharing options...
vmars316 Posted January 26, 2016 Author Share Posted January 26, 2016 10 hours ago, cdelstad said: Using the debug puts a green border around your sprites so you can tell real vs. apparent size. Ah , Thanks . Link to comment Share on other sites More sharing options...
Recommended Posts