Jump to content

ScavaJripter

Members
  • Posts

    3
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://narric.com

Profile Information

  • Gender
    Male
  • Location
    Provo, UT
  • Interests
    Learning Code.

ScavaJripter's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Oh, is that what this page is talking about? http://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection Yeah, its like I'll read things and I'll wonder to myself if that is the normal way of doing something. Thanks.
  2. I have no idea how to check for collision on only a small part of an image or sprite. For example, in the Image below, how would I detect collision with the sword in the red circle, but not detect collision with anything else in the blue square. I just want the sword to kill enemies and not the rest of his body or the white space above and below the sword. Another example, if my character is standing over a gap, my code sees his width as the width of his whole image (from his sword to the other arm) , and so he doesn't fall in the gap. How could I do collision detection with only a small part of the image? Could someone tell me what the technique is called or send me to an article to read. I don't even know where to begin looking. Thanks! PS. I am learning WITHOUT frameworks or libraries. I would like any help with just vanillaJS and later I'll learn a library.
  3. So my game, ( http://narric.com/underdog_football/ ), has this problem where i go through the tile map when I fall from high spots or if i jump up with high velocity. I have the gravity really high, when i lower it there is no problem, BUT I WANT THE GRAVITY HIGH! I don't think its a problem with the tile map because there is no problem when i lower the gravity and jump velocity. The code below isnt all the code for the game. (I normally have "preload" in another .js file and i got rid of the code for the intro screen and there is a boot file thats not included). I'm new to phaser and coding in general so any help is appreciated. var game = new Phaser.Game(1152,672, Phaser.AUTO, 'game_div');preload: function() { this.load.image('box', 'images/box.png'); // loading the tileset image this.load.tilemap('boxy', 'images/boxy.json', null, Phaser.Tilemap.TILED_JSON); this.load.spritesheet('player', 'images/football_sprite20.png',72,132,20); },create: function() { this.physics.startSystem(Phaser.Physics.ARCADE); map = this.add.tilemap('boxy'); // Preloaded tilemap map.addTilesetImage('box'); // Preloaded tileset layer = map.createLayer('Tile Layer 1'); layer.resizeWorld(); map.setCollisionBetween(0, 1); this.player = this.add.sprite(100, 100, 'player'); this.player.anchor.setTo(.5, 1); this.player.animations.add('walking', [0,1,2,3,4,5,6,7], 18, true); this.player.animations.add('sprinting', [12,13,14,15,16,17,18,19], 25, true); this.player.animations.add('jumping', [11], false); this.player.animations.add('idle', [8,9,10,9], 4, true); this.physics.arcade.enableBody(this.player); this.player.body.collideWorldBounds = true; this.player.body.bounce.y = 0.05; this.player.body.gravity.y = 5000; this.player.scale.x = 1; this.player.scale.y = 1; cursors = this.input.keyboard.createCursorKeys(); jumpButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);},update: function() { this.physics.arcade.collide(this.player, layer); this.player.body.velocity.x = 0; //====JUMPING==== jumpButton.onDown.add(jumpAction, this); function jumpAction(){ if (this.player.body.onFloor()) { this.player.body.velocity.y = -1400; this.player.body.gravity.y = 5000; this.player.animations.play('jumping'); if (cursors.down.isDown || sKey.isDown) { this.player.body.velocity.y = -1800; this.player.body.gravity.y = 5500; } } } //====MOVING LEFT==== if (cursors.left.isDown) { this.player.body.velocity.x = -500; this.player.scale.x = -1; this.player.scale.y = 1; if (cursors.down.isDown && this.player.body.onFloor()) { this.player.body.velocity.x = -730; this.player.animations.play('sprinting'); } else if(this.player.body.onFloor()){ this.player.animations.play('walking'); } } //====MOVING RIGHT==== else if (cursors.right.isDown) { this.player.body.velocity.x = 500; this.player.scale.x = 1; this.player.scale.y = 1; if (cursors.down.isDown && this.player.body.onFloor()) { this.player.body.velocity.x = 730; this.player.animations.play('sprinting'); } else if(this.player.body.onFloor()){ this.player.animations.play('walking'); } } //====STANDING IDLE==== else if(this.player.body.onFloor()){ this.player.animations.play('idle'); } }};
×
×
  • Create New...