-
Posts
24 -
Joined
-
Last visited
eloguvnah's Achievements
Newbie (1/14)
1
Reputation
-
I think I figured out a work around. Not sure if there is more sensible way, but I set a one second timer whether the "drop box" is allowed to be occupied. This allows for only one overlay at a time.
-
Hey guys, I'm creating a drag and drop interface and using arcade.overlap with onDragStop to position a sprite with a "drop zone" group. Unfortunately, the draggable sprite is large enough to cover two drop zones at the same ime. I have a custom property ("occupied") that is set to true while the sprite x,y is set to the drop zone x,y when a sprite is dropped and overlapping. Unfortunately, it does this for both drop zones in the group and both are "occupied" although only one x,y is used. Hope that makes sense. But my question is how do I only allow for only one sprite to be triggered on overlay?
-
satanas reacted to a post in a topic: Little help with my tilemap collision?
-
eloguvnah reacted to a post in a topic: sprite.body.touching.down always FALSE
-
eloguvnah reacted to a post in a topic: sprite.body.touching.down always FALSE
-
Awwww yea! That was it -- body.blocked will be stored in my brain matter now. Thanks! And thanks for the heads up on the collides -- I didn't even think about how many times it'd be checking for those collides. Perfect! Thanks!
-
Hm... still no luck, but I just realized I'm having issues with my layer as well... It's very strange -- sometimes the bullets from my player will collide with the tiles on my layer and sometimes it won't. I'm guessing there's a connection there. This may be deeper than I thought.
-
Hey guys, I'm back in the saddle working on my game but since updating my existing game to Phaser 2, I'm scratching my head on a few things. The first thing is that my grouped sprites are not registering the touching.down as they hit the layer. What am I doing wrong here? JumperBot.prototype = Object.create(Phaser.Group.prototype);JumperBot.prototype.constructor = JumperBot;JumperBot.prototype.update = function() { this.forEach(updateJumperBots, this, true);}// Update for each JumperBotfunction updateJumperBots(bot) { var playerPosX = player.x; var playerPosY = player.y; this.game.physics.arcade.collide(bot, layer); this.game.physics.arcade.overlap(bot, player.laser, jumperBotLaserShot); this.game.physics.arcade.collide(bot.jumperBullets, layer, layerShoot); this.game.physics.arcade.overlap(bot.jumperBullets, player.shield, jumperBulletShield); if ( playerPosX > bot.x && bot.body.touching.down ) { bot.facing = 'right'; } if ( playerPosX < bot.x && bot.body.touching.down ) { bot.facing = 'left'; } // JUMP if ( bot.body.touching.down ) { console.log('touching down'); if ( bot.facing == 'left' ) { bot.animations.play('jump-left'); bot.body.velocity.y = -375; bot.body.velocity.x = -150; } else if ( bot.facing == 'right' ) { bot.animations.play('jump-right'); bot.body.velocity.y = -375; bot.body.velocity.x = 150; } } // Check if Jumper is between 20 and -20 Y of the player var playerBotYdiff = playerPosY - bot.y; if ( playerBotYdiff < 20 && playerBotYdiff > -20 && bot.exists ) { bot.fire; }}
-
So I'm closer to figuring out why when I call the kill function on a laser hitting an enemy, the enemy disappears and not the laser. It's because it seems like the collide function is reversing the arguments depending on whether the lasers colliding with another sprite or if it's colliding with a tile. It's really weird. Laser.prototype.update = function() {game.physics.collide(this._laserGroup, layer, laserLayerCollideHandler, null, this);game.physics.collide(this._laserGroup, jumperBot._sprite, laserJumperBotCollideHandler, null ,this);game.physics.collide(this._laserGroup, turret._turret1Base, laserTurretCollideHandler, null ,this);} // end updatefunction laserLayerCollideHandler(laser, layer) {laserExplode(laser, layer, this);//laser.kill();console.log(laser);}function laserJumperBotCollideHandler(laser, jumperBot) {laserExplode(laser, jumperBot, this);//laser.kill();//console.log(jumperBot);}function laserTurretCollideHandler(laser, turret) {laserExplode(laser, turret, this);//laser.kill();//console.log(laser);}function laserExplode(laser, target, context) {if ( laser.body.touching.right ) {context._laserEmitter.x = laser.x + (laser.body.width );context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = -550;context._laserEmitter.start(true, 200, null, 5);} else if ( laser.body.touching.left ) {context._laserEmitter.x = laser.x;context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = 550;context._laserEmitter.start(true, 200, null, 5);}// var getIndex = context._laserGroup.getIndex(laser);// console.log(getIndex);// context._laserGroup.remove(getIndex);}If I set laser.kill() on the function handling collisions between the laser and the tile, the laser dies no prob, but in the collision with jumperBot or turret, it's the jumperBot or turret that's being killed. Does anyone know what's going on here? I could just make a separate collision handler for sprites vs. tilemap but that seems weird to me.
-
Ah... Yeah, I guess I don't know enough about the issue to figure it out. I have had issues with my game literally freezing my Macbook if running and it goes to sleep. Ugh.. Stuff beyond my knowledge of the subject.
-
Hey guys, I was running my game when Chrome game me the "Rats! WebGL hit a snag..." warning which lead me here: https://support.google.com/chrome/answer/2905826?p=ib_webgl&rd=1 Any ideas why?
-
Hey guys, On collision between an enemy and a laser (within a group) I kill the laser but the enemy is also being killed. Bug or something I'm doing wrong? Laser.prototype.update = function() {game.physics.collide(this._laserGroup, layer, laserLayerCollideHandler, null, this);game.physics.collide(this._laserGroup, jumperBot._sprite, laserJumperBotCollideHandler, null ,this);} // end updatefunction laserLayerCollideHandler(laser, layer) {laserExplode(laser, layer, this);}function laserJumperBotCollideHandler(laser, jumperBot) {laserExplode(laser, jumperBot, this);}function laserExplode(laser, target, context) {if ( laser.body.touching.right ) {context._laserEmitter.x = laser.x + (laser.body.width );context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = -550;context._laserEmitter.start(true, 200, null, 5);} else if ( laser.body.touching.left ) {context._laserEmitter.x = laser.x;context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = 550;context._laserEmitter.start(true, 200, null, 5);}laser.kill();}My repo: https://github.com/googaloo/upgrader Thanks guys, you're the best!
-
And thats a good place to start! Thanks
-
Hey guys, I've been having computer freeze issues that I'm pretty sure is a memory leak from my Phaser game. I'm almost 100% sure it's my own fault but I don't know enough about the issue to know where to even start looking. Anyone else run into this issue or know enough about it to help? Here's my repo: https://github.com/googaloo/upgrader
-
Pixelguy just achieved 1000 points! Thank you, kind sir. It's working Although if I set gravity to any value, my player disappears for some odd reason. I'll have to do some investigation but otherwise it's totally working. It was the velocity issue. @RaptorZen64, that's a good idea too. In fact, that gives me some ideas for the future actually.
-
Hey guys, I try to figure these things on my own but I'm on day 3 of troubleshooting these tilemaps. Here's the code. Essentially, the player isn't colliding with with the collidable tiles of the tilemap but it looks like my jumperBot sprite is but with all tiles, not just the set collision tiles. If you can help me figure this out, I will grant you a 1000 points! function preload() {game.load.image('player', 'assets/player.png');game.load.spritesheet('jumperBot', 'assets/jumper-bot.png', 48, 98);game.load.tilemap('level1', 'assets/cave_tilemap.json', null, Phaser.Tilemap.TILED_JSON);game.load.tileset('tiles', 'assets/cave_tiles.png', 32, 39);}function create() {// TILEMAPmap = game.add.tilemap('level1');tileset = game.add.tileset('tiles');tileset.setCollisionRange(1, 6, true, true, true, true);tileset.setCollision(7, false, false, false, false);layer = game.add.tilemapLayer(0,0,800,600,tileset,map,0);// JUMPERBOTjumperBot = game.add.sprite((game.world.width - 275), (game.world.height - 250), 'jumperBot');jumperBot.body.collideWorldBounds = true;jumperBot.body.gravity.y = 6;jumperBot.animations.add('jump', [1,2,0], 12, false);jumperBot.animations.add('idle', [1], 10, false);}function update() {game.physics.collide(jumperBot, layer);game.physics.collide(player, layer);}
-
Ah, this is exactly what I was looking for on here. Can't wait for the tutorial!