alessandronunes

Members
  • Content Count

    11
  • Joined

  • Last visited

About alessandronunes

  • Rank
    Member

Recent Profile Visitors

738 profile views
  1. Hello! On free time, I'm trying to make a Soccer (Football) game with RTS mechanics. The idea came through while I was playing Clash Royale, and I love some RTS elements like top-down / isometric view and watch the character IA change the environment interacting with each other. The project is shared here: https://github.com/alessandronunes/soccerpunch/ I know I have to adjust the velocities and make better IA, but I'm a little stuck here, so I would like to listen to some opinion: what would you do to make of this a (good) game? Thank you!
  2. And if you use physics: sprite.kill(); sprite.body = null;
  3. What I did on another game (Using Box2D) was to create a floating canvas to render the fog. <canvas id="fog"></canvas> <script> Game.fog = document.getElementById("fog"); Game.fog.width = Game.canvasSize; Game.fog.height = Game.canvasSize; Game.fog.context = Game.fog.getContext("2d"); Game.fog.context.fillStyle = 'black'; Game.fog.context.fillRect(0, 0, Game.canvas.width, Game.canvas.height); Game.fog.context.globalCompositeOperation = 'destination-out'; touchCanvas = Game.fog; Game.fog.context.save(); Game.fog.context.globalCompositeOperation = 'source-over'; Game.fog.context.fillRect(0, 0, Game.canvas.width, Game.canvas.height); Game.fog.context.restore(); Game.fog.context.globalCompositeOperation = 'destination-out'; Game.fog.context.save(); var x = Game.player.x*Game.scale; var y = Game.player.y*Game.scale; var grad = Game.fog.context.createRadialGradient(x, y, 0, x, y, Game.scale*1.5); grad.addColorStop(0, "rgba(0, 0, 0, 1)"); grad.addColorStop(.5, "rgba(0, 0, 0, .1)"); grad.addColorStop(1, "rgba(0, 0, 0, 0)"); Game.fog.context.beginPath(); Game.fog.context.fillStyle = grad; Game.fog.context.arc(x, y, Game.scale, 0, 2 * Math.PI, !1); Game.fog.context.fill(); Game.fog.context.restore(); </script> You track the character position and then use the Path to clean the area. I could send the entire code if you like.
  4. Hello @mariante, as @carlosnufe said, please post the ball code. I had the same problem on my project, and solved refactoring the code. Try this: Create sprite Add body to sprite Add sprite to group Check collision on Update To debug, I sugest: this.barreiraGroup.forEach(function(barreiras){ //Check if loop and objetcs are ok and have physics console.log(this.ballSprite, barreiras); this.game.physics.arcade.collide(this.ballSprite, barreiras); }, this);
  5. Hello @Ashish, please check this example: http://phaser.io/examples/v2/basics/04-image-follow-input On Update function you can use moveToPointer, moveToXY or moveToObject: function update () { // If the sprite is > 8px away from the pointer then let's move to it if (game.physics.arcade.distanceToPointer(sprite, game.input.activePointer) > 8) { // Make the object seek to the active pointer (mouse or touch). game.physics.arcade.moveToPointer(sprite, 300); } else { // Otherwise turn off velocity because we're close enough to the pointer sprite.body.velocity.set(0); } }
  6. Hello @mariante, I'm using the code bellow on this project (https://github.com/alessandronunes/soccerpunch/ - Check for examples): function create(){ boundsGroup = game.add.group(); boundsGroup.enableBody = true; createBoundLine(0,0,40,960); createBoundLine(500,0,40,960); createBoundLine(0,0,540,120); createBoundLine(0,840,540,120); } function update(){ game.physics.arcade.collide(playerGroup, boundsGroup); game.physics.arcade.collide(ball, boundsGroup); } function createBoundLine(x,y,w,h){ var line = boundsGroup.create(x, y, null); line.body.setSize(w, h, 0, 0); // set the size of the rectangle line.body.immovable = true; line.body.moves = false; line.body.allowGravity = false; }
  7. Thanks @LTNGames and @samme. I'll try to split the file this way.
  8. Great game @enriqueto! I'm looking for some ideas for another Soccer game (https://github.com/alessandronunes/soccerpunch/), but the physics are quite different.
  9. Hello, I started a hobby project to learn Phaser (https://github.com/alessandronunes/soccerpunch). It's lika a Clash Royale Soccer, with punchs (not implemented yet). The code is growing and I need to split the game logic in more than one file. I have knowledge of some Javascript frameworks, like Sencha and JQuery Mobile, and I'm familiar to the MVC concept. I'll probably try to create files for every game object (Player.js, Goal.js, Ball.js, etc.). So I would like to ask: how do you organize your code files? Please send examples!
  10. Hello Aaron, What I'm doing is put my project on GitHub: github.com And then activate the GitHub Pages (Settings -> GitHub Pages). My project: https://github.com/alessandronunes/soccerpunch The generated page: https://alessandronunes.github.io/soccerpunch/