billmo

Members
  • Content Count

    9
  • Joined

  • Last visited

About billmo

  • Rank
    Newbie

Contact Methods

  • Twitter
    @beaucostoff

Recent Profile Visitors

666 profile views
  1. I recently purchased the Box2D plugin for phaser and have been playing around with it with some success. I've now moved onto the point where I would like to make some custom polygons but am having trouble finding answers on the easiest way to do this. I looked at the Phaser docs and essentially want to do something like the following https://phaser.io/examples/v2/box2d/car-on-terrain. All seems pretty straight forward except for the polygon creation. Where did the vertices come from? How did the flattened xy coordinates come to be? I tried purchasing RUBE but there seems to be nothing that exports like so. Either that, or there just isn't enough helpful information out there regarding integrating RUBE polygons with Phaser. In fact, much of what I have found recently suggests that RUBE doesn't even play well with Phaser anymore. If anyone could point me in the right direction, that would be hugely appreciated. At this point, I feel like I wasted my money on the Box2D plugin.
  2. I know this is old, but what does gameSize refer to when setting the value to the resolution variable?
  3. billmo

    Circular World

    Hmmm. That does sound like an interesting concept. There are physics on it, but maybe I can worry about that step next.
  4. billmo

    Circular World

    Would that result in a seamless transition though in regards to the level background? I would have the camera following the player so I'm just not sure how the actual tilemap's end point would connect back to the tilemap's beginning point. Imagine it as a 2 dimensional view of the earth but unraveled so that it doesn't appear that you're walking on actual circle.
  5. billmo

    Circular World

    Need some help and hoping someone will know an answer. I'm trying to create a tilemap world where if the player continues to walk right, eventually they end up back at the beginning of the stage. Does anyone have any idea how this is accomplished?
  6. Ok, need some help/ guidance on what to do. What I have now is a sprite that is being generated randomly using simplex noise. I have successfully masked out the background so I'm left with just the terrain. I will be using this as my ground sprite for each level in my game. So my problem comes to collisions. If I am generating the level's terrain on the fly, how would I go about making player collide with it? I have found some fancy software that you can actually trace out the object and with a click it will generate a polygon shape .json file, but this only works if you have the image prior to using it - which I don't. Any guidance would be greatly appreciated.
  7. I'm replying to myself in case anyone else runs into this issue. Here is how I solved it. I created a function to get random x,y coordinates and then ran them through the getTileWorldXY function to retrieve the tile index of the random coordinates. If the tile matched my floor tile, I just re-run the function. function getRandomCoordinates(){ var randX = Math.floor((Math.random() * game.world.width) + 1); var randY = Math.floor((Math.random() * game.world.height) + 1); var tileId = map.getTileWorldXY(randX,randY,32,32,blocks,true).index; if(tileId == 317){ getRandomCoordinates(); }else{ randomX = randX; randomY = randY; return; } }
  8. Hey Guys, New to Phaser and need help in an issue I'm running into. I'm trying to randomly create a sprite (the coin) in my stage but want to check if it's overlapping with a particular tile before showing. If it does overlap, I want to kill it and create it in a new position. I don't even know if this is the best approach, but it's what I've been trying. So far, I can't get it to work. The sprite has no issues being created overlapping the tile I've been trying to have it avoid. Here's my code so far: window.onload = function() { var game = new Phaser.Game(640, 640, Phaser.AUTO, '', { preload: preload, create: create, update: update }); var map; var heart; var backgroundLayer; var blocks; var player; var coin; var jumptimer = 0; var arrow; var arrows; var arrowTime = 0; var score_counter = 0; var remaining_arrows = 40; var score_text; var arrows_text; var last_clicked; var new_remaining_arrows; function preload () { game.load.tilemap('myMap', 'tilemaps/test_tilemap.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('sheet', 'tilemaps/scifi_platformTiles_32x32.png'); game.load.spritesheet('dude', 'images/bear-dude.png', 36, 38); game.load.image('arrow', 'images/arrow.png'); game.load.image('heart', 'images/heart.png'); game.load.spritesheet('coin', 'images/coin-sprite-animation-sprite-sheet.png', 44, 40); } function create () { game.physics.startSystem(Phaser.Physics.ARCADE); //Tilemap map = game.add.tilemap('myMap'); map.addTilesetImage('scifi_platformTiles_32x32', 'sheet'); backgroundLayer = map.createLayer('Background'); blocks = map.createLayer('Blocks'); map.setCollision(317, true, blocks); backgroundLayer.resizeWorld(); //Heart game.add.sprite(20, 20, 'heart'); //Coin coin = game.add.sprite(Math.floor((Math.random() * game.world.width) + 1),Math.floor((Math.random() * game.world.height) + 1), 'coin'); coin.scale.setTo(.5,.5); game.physics.arcade.enable(coin); coin.enableBody = true; coin.body.collideWorldBounds = true; //Arrow arrows = game.add.group(); arrows.enableBody = true; arrows.physicsBodyType = Phaser.Physics.ARCADE; arrows.createMultiple(40,'arrow'); arrows.setAll('checkWorldBounds', true); arrows.setAll('outOfBoundsKill', true); // Player player = game.add.sprite(32, game.world.height - 150, 'dude'); player.scale.setTo(1.2,1.2); game.physics.arcade.enable(player); player.body.bounce.y = 0.1; player.body.gravity.y = 300; player.body.collideWorldBounds = true; //Animations player.animations.add('left', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 12, true); player.animations.add('right', [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 12, true); player.animations.add('jump_left', [26], 12, true); player.animations.add('jump_right', [25], 12, true); coin.animations.add('spin', [0,1,2,3,4,5,6,7,8,9], 24, true); //Text Elements score_text = game.add.text(0, 0, "Score\n" + '0', { font: "18px Arial", fill: "#ffffff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" }); score_text.setTextBounds(0, 0, 640, 80); arrows_text = game.add.text(540, 20, "Arrows: " + (remaining_arrows), { font: "18px Arial", fill: "#ffffff" }); //Keyboard Elements cursor = game.input.keyboard.createCursorKeys(); game.input.keyboard.addKeyCapture([ Phaser.Keyboard.SPACEBAR ]); } function update() { game.physics.arcade.collide(player, blocks); game.physics.arcade.collide(arrows, blocks, stopArrow, null, this); game.physics.arcade.collide(coin, blocks, replaceCoin, null, this); game.physics.arcade.collide(arrows, coin, shootCoin, null, this); game.physics.arcade.overlap(player, coin, collectCoin, null, this); coin.visible = true; coin.animations.play('spin'); player.body.velocity.x = 0; if (cursor.left.isDown){ // Move to the left player.body.velocity.x = -150; if(!player.body.blocked.down){ player.animations.play('jump_left'); }else{ player.animations.play('left'); } last_clicked = 'left'; }else if (cursor.right.isDown){ // Move to the right player.body.velocity.x = 150; if(!player.body.blocked.down){ player.animations.play('jump_right'); }else{ player.animations.play('right'); } last_clicked = 'right'; }else{ // Stand still player.animations.stop(); player.frame = 12; } // Allow the player to jump if they are touching the ground. if (cursor.up.isDown && player.body.blocked.down) { if(last_clicked == 'left'){ player.animations.play('jump_left'); }else if(last_clicked == 'right'){ player.animations.play('jump_right'); } player.body.velocity.y = -350; } // Fire Arrow if (game.input.activePointer.isDown){ fireArrow(); } } function fireArrow(){ //Fire Arrows if(game.time.now > arrowTime){ arrow = arrows.getFirstExists(false); if(arrow){ arrow.reset(player.body.x + 16, player.body.y + 16); arrow.rotation = game.physics.arcade.angleToPointer(arrow); game.physics.arcade.moveToPointer(arrow, 300); arrowTime = game.time.now + 100; new_remaining_arrows = remaining_arrows - arrows.total; arrows_text.setText("Arrows: " + (new_remaining_arrows)); } } } function collectCoin (player, coin) { // Removes the coin from the screen coin.kill(); arrows.createMultiple(10,'arrow'); remaining_arrows = new_remaining_arrows + 10;; arrows_text.setText("Arrows: " + remaining_arrows); score_counter = score_counter + 500; score_text.setText("Score\n" + score_counter); addCoin(); } function shootCoin (coin, arrow) { // Removes the coin from the screen coin.kill(); arrows.createMultiple(5,'arrow'); remaining_arrows = new_remaining_arrows + 5; arrows_text.setText("Arrows: " + remaining_arrows); score_counter = score_counter + 100; score_text.setText("Score\n" + score_counter); addCoin(); } function stopArrow (arrow) { arrow.body.velocity = 0; } function addCoin(){ //Add coin coin = game.add.sprite(Math.floor((Math.random() * game.world.width) + 1),Math.floor((Math.random() * game.world.height) + 1), 'coin'); coin.visible = false; coin.scale.setTo(.5,.5); game.physics.arcade.enable(coin); coin.enableBody = true; coin.animations.add('spin', [0,1,2,3,4,5,6,7,8,9], 24, true); } function replaceCoin(){ alert('Test Collision.'); //coin.kill(); //addCoin(); } };