vmars316

Phaser: green shadow on my sprite *.png s ??

Recommended Posts

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);

}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.