Search the Community

Showing results for tags 'Physics'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 668 results

  1. Zef

    Phaser Update Speed

    Hi there, I am currently using phaser for a simulation of life evolving a neural network inside little creatures. This relies on generation after generation of these creatures being evolved with a genetic algorithm. I am currently relying on the arcade physics system to handle collisions and overlaps etc, and the little creatures survive by eating food, and hunting each other. Or at least that is what they should learn to do. Currently each round last 45 seconds, this in itself isn't a problem, but I have been trying to find a way to step the Phaser engine at the fastest speed possible so that I can complete a number of simulations in the shortest possible time. It can take 1000s of generations before the creatures evolve to show intelligent behaviour. I am struggling to achieve this at present. I have tried using game.enableStep() and then in the update function calling game.step() more than once but this doesn't appear to work. Does anyone know how I can do this? Thanks for you help. ps. I have made a little site showcasing the neural network http://jozefmaxted.co.uk/neural/index.html I plan to add more examples and will put the code up on Github soon. Its the sort of thing that will be really handy for creating AI for games.
  2. Is there a simple way to lock the x or y axis of a p2js body? I ask because I need to keep a group of objects within columns, I'm hoping I can avoid creating new column-gutter sprites just to separate the columns.
  3. when i switch to p2js I can't seem to debug physics at all (I dont see any overlays). So here is what i am doing oncreate this.pandas = game.add.group(game.world, 'pandas', false, true, Phaser.Physics.P2JS); this.pandas.createMultiple(28, 'panda');onupdate at certain intervals I fetch a panda! var panda = this.pandas.getFirstExists(false); if (!panda) { return; }...panda.reset(x, y);panda.debug = true;render this.pandas.forEachAlive(function(panda) { game.debug.body(panda); });
  4. Hi, I am new to phaser and I am programming a version of asteroids to get my sealegs. I wanted to take advantage of the bitmap data to create colorful gradient sprites for the ships lasers but I'm discovering the limits of arcade physics pretty quickly. I right now have a group of lasers which are bmd generated sprites. When the ship fires it grabs a random child and revives it, prints it, checks for bounds with the asteroid then is killed the next cycle. It looks great but with how the bounding box collision tests work — checking for collisions without physics — the laser collision test tells me true even when the laser clearly doesn't hit because of the ol' a^2 + b^2 = C^2. I eventually want to turn the asteroid's physics bounds into polygons too for less hilariously random player deaths. I've read a bit about SAT.js but I can't find documentation for the support in PHASER and I'm unclear about the limits of arcade physics. What would checking phaser lines, or angled sprites for collision with a polygon look like? Do I have to switch to PS to do line/ rectangle collision? Is this just a really silly way of doing this? Should I switch to an emitter (I might do that anyway for, like, really sweet machine gun effects). Thanks!
  5. Hi all, I know this has been asked before, but I still couldn't get any clarity after reading those other posts. Every time I try to destroy an object when it passes out of bounds I get an error, usually: Uncaught TypeError: Cannot read property 'camera' of null I understand that I'm probably trying to do something with that object when it is already destroyed... the problem is I don't know what. The object is in a group which is being checked for collisions against another group. It also has a physics body. I've tried removing the object from its group before destroying it, but still no dice. Any guidance is appreciated - Nick
  6. I am a newbie to game dev and Phaser. My scenario is this. I have a rectangular sprite(Initial angle 0 degrees) that rotates about its base. There is another rectangular sprite below it which gets overlapped by the rotating sprite at each rotation. Collision without rotation works for me. But I am unable to detect the collision when the first sprite rotates. Please help me sort this issue. I use arcade physics. My code is below. function create() { sprite1 = game.add.sprite(100, 100, "sprite1"); sprite1 = game.add.sprite(100, 150, "sprite1"); game.physics.enable(sprite1, Phaser.Physics.ARCADE); game.physics.enable(sprite2, Phaser.Physics.ARCADE); }function update() { sprite1.angle += 1; game.physics.arcade.collide(sprite1, sprite2, collisionHandler, null, this);}function collisionHandler(obj1, obj2){ console.log("Collided");}
  7. Hello ! I have a problem, I don't know if this behavior is the one expected (physics.p2). Here it is: I have a player with doesn't move on the screen, I make platforms come to the player with no friction so the player still doen't move and slide on the platforms. The problem is that the player velocity is taking bigger and bigger values, it's increasing insanly even if the player doen't move. If I set the player velocity to 0 each update, it works the same way... I just don't understand why is it increasing ? It's causing me problems in the devloppement of my game :-( Thanks :-)
  8. Can anyone tell me or suggest how the polygons were created in the phaser examples? I wanted to make complex shapes like that for collision/p2 physics but am having some difficulty finding how they're made. http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=load+polygon+1.js&t=load%20polygon%201 http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=load+polygon+2.js&t=load%20polygon%202 I apologize if this is a real n00b question but I was actually having trouble finding out.
  9. Hi, I'm newbie in development of games in HTML5. During this weekend I made my first HTML5 game with Panda game engine. It's quite simple, your goal is to build the tallest tower from various bricks and let building stands as long as possible. Game using p2.js plugin for physics. You can play it here: http://crazybricks.clay.io Thanks to @enpu for great work around Panda engine.
  10. I ran into this in a little game I'm building, but I've managed to boil it down to a simple example that illustrates the problem (I modified the Arcade Physics "sprite vs sprite" example). sprite2 falls under gravity until it lands on sprite1, then after sitting there for one frame (essential to demo the bug) it gains a steadily increasing upwards force. Expected: sprite2 will take off and fly up to the top of the screen. Actual: sprite2 sticks to sprite1 and tows it up to the top of the screen. If we enable sprite1.immovable, sprite2 will stick to sprite1 (and not move upwards) regardless of the amount of force applied. var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });function preload() { game.load.image('atari', 'assets/sprites/atari130xe.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png');}var sprite1;var sprite2;var force2 = 0;var takeOff2 = false;var count2 = 0;function create() { game.physics.startSystem(Phaser.Physics.ARCADE); sprite1 = game.add.sprite(300, game.world.height, 'atari'); sprite2 = game.add.sprite(300, game.world.height - 200, 'mushroom'); game.physics.enable([sprite1, sprite2], Phaser.Physics.ARCADE); sprite1.name = 'atari';// sprite1.body.immovable = true; sprite1.body.collideWorldBounds = true; sprite2.name = 'mushroom'; sprite2.body.gravity.y = 100; sprite2.body.collideWorldBounds = true;}function update() { if (takeOff2) force2 -= .5; sprite2.body.velocity.y += force2; game.physics.arcade.collide(sprite1, sprite2, collisionHandler, null, this);}function collisionHandler (obj1, obj2) { // let it sit in contact for one frame before attempting to take off if (count2++ > 0) takeOff2 = true;}function render() { game.debug.text("force " + force2, 0, 50);}
  11. Hello there I have a simple question: Is it possible to enable only one or two faces of a polygon body ? Furthermore, would it make me gain performances ? Is it worth it ? Thank you Edit: In fact I'm talking about the physic properties (will it collides or not), maybe it wasn't clear in my post.
  12. I have a set of pins set up on a board and I want the ball to get a specific velocity when it collides with a pin in order to guide it to a predetermined destination. basically every time the ball collides with a member of the pins group I do a check to see if the ball should be falling left or right and then force that velocity on the ball, this is designed to ensure that the ball falls in the correct predetermined slot. at the moment I'm using the phaser overlap function: this.physics.overlap(coins, pins, moveCoin, null, this); where move coin looks like this: function moveCoin(coin, pin){ if(shouldMoveRight(coin)) coin.body.velocity.x=100; else coin.body.velocity.x=-100;} Now my issue is that this function seems to only work some of the time and not others. This is pretty confusing and I do not quite understand why that would be the case. Is there a better way for me to implement this or is there something i'm doing wrong? I've tried using the collide function as well with the same effect. Some help will be massively appreciated!
  13. Hello, I would like to create a sprite (with a texture and a polygon body) without adding it to the world. I know that without game.add.existing(myEnnemy); it will not be shown, but his body IS in the world (yeah that's strange). Thank you Edit: I would like a kind of SpriteFactory actually with the ability to create multiple instance of the same sprite. Like this: Ennemy = new Ennemy(x,y, key, body);var ennemy1 = Ennemy.createNew();var ennemy2 Ennemy.createNew();var ennemy3 Ennemy.createNew();But it seems a bit complicated.
  14. Holla, amigos! How to slow moving of bodies in P2 physics? I need to substrat 1 pts from body speed per second.
  15. hey, again i'm lost with Ninja Physics i have a map of objects which could be collected by a player gpObjs = game.add.group();game.physics.ninja.enable(gpObjs); map.createFromObjects('objs', 42, 'coin', 0, true, false, gpObjs);map.setTileIndexCallback(42, this.onHit, this);gpObjs.forEach(function(item) { game.physics.ninja.enableBody(item); item.body.immovable = true;})on the update(), i did not manage to detect overlap, it's always false var hit = game.physics.ninja.overlap (player, gpObjs, onHit, null, this);what's wrong with my code ? did i use convertTileMap() instead of createFromObjects() ? i read i can't use collisionGroup with ninja but i can use Group ?
  16. When i switch browser tab then back to the game tab the player sprite is fall through the floor. Steps to reproduce: - open this link http://baldricksoft.com/csuszos/ need a few sec till load. Tilemap layer and player debug info is turned on. - wait until the player sprite reach the first wall - switch browser tab then back to the game tab - watch how the sprite fall through the floor and die Any idea how to avoid that? The code is mostly from the phaser examples. UPDATE: Its only happens with this.game.stage.disableVisibilityChange = true; it is normal? SOLUTION: if some1 have the saem problem, adjust the this.game.physics.arcade.TILE_BIAS to 64;
  17. Hi guys, I have just started tries to make small games using phaser and decided to start from something very usual - tetris. So I am sorry for my stupid questions but I have spent some time trying to resolve the question by myself but without any success. As we know each tetris' figure consists from 4 blocks. Also I want to add some physics to my game. And this is the main issue that I have faced. 1. Can I use simple rectangle and not sprite as physics body? 2. If I am using sprite I have 1 block. As far as I have understood I need to create a joint from 4 such blocks to have one solid figure. Am I right? Or there should be used another way. Also if yes, how can I create such joint? P.S. any tutorials with tetris or something similar with usage of phaser will be very useful. Thanks and sorry for my stupid questions
  18. Hi there! Is there a way to get load polygons of each sprite (from physics editor) on a sprite sheet and apply the physics? Thanks!!
  19. Here again. My circles are ignoring world bounds. So there is code: this.game.world.setBounds(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);this.game.physics.startSystem(Phaser.Physics.P2JS);this.game.physics.p2.restitution = 0.8;this.game.physics.p2.updateBoundsCollisionGroup();//...////...////...//chipsCollisionGroup = this.game.physics.p2.createCollisionGroup();this.chips = this.game.add.group();this.chips.enableBody = true;this.chips.physicsBodyType = Phaser.Physics.P2JS;//...////...////...//function setupChip(chip, owner, game) { if (chipsCount[owner] < 1) return false; var MAX_MASS = 6; var mass = Math.ceil(Math.random() * (MAX_MASS - 1)) + 1; chip.scale.setTo(convertY(CHIP_SIZE / MAX_MASS * mass) / 64); chip.mass = mass * 100; chip.anchor.setTo(0.5, 0.5); chip.tint = PLAYERS_COLORS[owner]; chip.owner = owner; chip.dragging = false; chip.body.setCollisionGroup(chipsCollisionGroup); chip.body.collides(chipsCollisionGroup); chip.body.setCircle(chip.width / 2); chip.inputEnabled = true; chip.input.start(0, true); chip.events.onInputDown.add(drag); chip.events.onInputUp.add(stopDrag); return true;}//Usally previous function calls like thisvar chip = state.chips.create(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 'chip');setupChip(chip, PLAYER_FIRST, state.game);
  20. yegorf1

    Circle physics

    Hello! I tried to make my game with physics. Prototype you can find here. First goes blue, than red, green, yellow. You can't win or lose, yet. As you can see, I use circles, but I use Phaser.Physics.ARCADE too and it doesn't support circles, so now there're squares instead of circles. How can I fix it? .Sorry for bad english
  21. Hello! If i use a high Y velocity on tilemap the collide event is not fired. Here is an example: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=map+collide.js&t=map%20collide After I modify the p.body.velocity.y = -200; line to p.body.velocity.y = -2000; and try to jump under the first platform the phaser-dude sprite is jump through the platform. Is there a way to avoid that? Thank You.
  22. Hi, I have recently used phaser and p2 for a university project. Just wondering if anyone would be interested in an example if I put one together? Also, do you think this is something that would interest the guys at Phaser to the point where they could maybe post it in the examples? I used the P2 example from schteppe's Github and had a little help from him too. I would have to work to make it better to show it as an example, but its not bad. Had a little trouble with the scale of physics, tried setting the overall mass to 80 units(whatever they may be) and the gravity to 10 and it did not work, so think I have to figure out the physics units. Tried the pixel to p2 unit conversions with no luck either. I am willing to put in a bit of effort and make a reasonable example if it interests people. Here's a very buggy quick demo, had just finished ragdoll but not implemented any game features. https://www.youtube.com/watch?v=GhXOPfzVYmM As I said needs work, but let me know if anyones interested as I dont fancie putting in the work for no reason! Cheers.
  23. Hello, I started a small sandbox game with Phaser and I have this problem. I can rotate the car, but collision box does not rotate. I don't understand how to rotate both of them :/ I attached the screenshot and code is here: http://pastebin.com/pUh1jd7L How to rotate the collision box together with the sprite?
  24. Hi there, I was just wondering if it's possible to lock the rotation of a body in p2, so it would behave like it would in arcade physics. Or is it possible to mix and match physics bodies between engines? Sorry, kinda new at this. Thank you in advance!
  25. I've noticed that it's impossible to get an object to overlap(as opposed to collide) with a tilemapLayer! Why? And how do I overcome this? I'm using arcade physics: this.game.physics.arcade.overlap(this.sprite, level.layer, this.hitWall, null, this);It just bounces off! Please, any help is appreciated!