Search the Community

Showing results for tags 'Physics'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 668 results

  1. Why aren't the physics engines stand-alone/plugin projects? Would it not be possible to have an adapter layer that must implement some interface for passing back collision data so that we could use which ever physics engine we wished and without having the bloat of trying to wrap other physics engines into Phaser? I'm asking this both from an academic and practical point of view. Is it slower to do it that way? Is it something you considered/attempted and decided it wasn't gonna work? Was it completely unfeasible? Just curious.
  2. Hello. I want to use the physic arcade with objects that have physic p2. I get an error console. Uncaught TypeError: Can not call method 'setTo' of undefined Any help with that?
  3. Hello, I have nearly finished a platform game I have made in Phaser. The game runs mostly fine, however sometimes when the state is changed to a new level and the player sprite is created, it falls through the floor tile, hence losing a life and restarting the level. I'm not sure why this is and it doesn't happen very often but does occasionally which seems odd. I would be grateful for any info as to what might be causing this. Cheers!
  4. Hi all, I'm having a few issues with Phaser 2.0, typescript and physics and hope that someone can point me in the right direction. Not sure if my error is because the phaser.d.ts might be incomplete or I'm just missing something. I'm simply trying to init Arcade physics by calling...;This compile error I receive is... The property 'startSystem' does not exist on value of type 'Phaser.Physics.Arcade.World'.If I try and use.. new Phaser.Physics.Arcade(;... I don't get the compile error. Pretty much any other calls to a sprite's body or other physics functions cause an error too. Thanks for the help. -- Mark
  5. Hi there, I'm trying to get off the ground with creating my own phaser games, but I've hit a blocker that I just can't work out. I have a very basic setup, based on the Phaser Tutorial examples: index.htmljsphaser.min.jsassetsstarfield.pngThis is my very, very basic index.html code - but it falls over at the first hurdle when I try to access a game.physics method: <!doctype html><html> <head> <meta charset="UTF-8" /> <title>hello phaser!</title> <script type="text/javascript" src="js/phaser.min.js"></script> </head> <body> <script type="text/javascript"> window.onload = function() { var game = new Phaser.Game(1900, 1000, Phaser.AUTO, '', { preload: preload, create: create }); function preload () { game.load.image('starfield', 'assets/starfield.png'); } function create () { game.physics.startSystem(Phaser.Physics.ARCADE); // The scrolling starfield background starfield = game.add.tileSprite(0, 0, 1900, 1000, 'starfield'); } }; </script> </body></html>In Chrome I get the following error: Uncaught TypeError: Object #<Object> has no method 'enable' (index):48 create(index):48 d.StateManager.loadCompletephaser.min.js:4 d.Game.loadCompletephaser.min.js:5 d.SignalBinding.executephaser.min.js:4 d.Signal.dispatchphaser.min.js:4 dispatchphaser.min.js:4 d.Loader.nextFilephaser.min.js:10 d.Loader.fileCompletephaser.min.js:9 This is all running locally under Apache. I have tried a few other basic things, but whenever I try to access any Phaser object methods I get this same 'Uncaught TypeError' issue. I have phaser-examples set up locally, and these run just fine - as do the Phaser Tutorial examples. I have been trying to just build out from the tutorials to experiment and get to grips with everything. I assume it's a really dumb error, but I just can't see where I'm going wrong. Any tips would be gratefully accepted. Thanks, Stu
  6. I am very new in the html5 and game development and I am very impressed with the engines, specially Phaser. I am developing a 2D game based on the Tank example available at Currently, I am trying to physics to the bullet group, but I read in the post from yesterday that is not possible The idea is to shoot when when clicked and the bullets should lose height and speed as it cross the screen. Here is revelant part of the code: function create() {... // Our bullet group bullets =; bullets.createMultiple(30, 'dude'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 0.5); bullets.setAll('outOfBoundsKill', true);function update() { if (game.input.activePointer.isDown) { // Boom! fire(); }}function fire () { if ( > nextFire && bullets.countDead() > 0) { nextFire = + fireRate; var bullet = bullets.getFirstDead(); bullet.reset(weapon.x, weapon.y); bullet.rotation = game.physics.moveToPointer(bullet, 1000); }}Any idea of how to implement it ? Regards
  7. zxxz

    Default drag

    Hey I have a feature where a sprites velocity becomes the velocity of a moving platform when landing on it which worked fine. I have now however tweaked some of the controls including the drag.x and now when riding the platform the sprite slips off? I have also tried to change the drag to 0 when the sprite is on the platform but I get he same thing happen? Not sure of there is a way to essentially turn drag off or to whatever it is initially? Thanks
  8. Hi, I'm tring to port an old game to 2.0 and I can't find the body.allowrotation for Arcade Physicsm do I need to change the physics engine to rotate my sprite body ?
  9. Hello, folks! I'm making simple game, "Landing on the Mars". This is a link Currently, I'm stuck with the ground generation. I'm using a poligon to emulate uneven ground. But, in this case, physics system works wrong Collision doesn't happen with polygon body, but little above its borders. I've tried to play with body.translate(), but got nothing And second question, how can I fill the ground polygon with texture? I've tried Pixi mask, but no luck Any help very appreciated! :-) Code: function groundGenerator(){ var points = []; points.push(0); points.push(getRandomInt(0, 50) - 30); for(var x=getRandomInt(50, 150); x<1024; x+=getRandomInt(10, 100)) { points.push(x); points.push(getRandomInt(0, -150) + 10); } points.push(1024) points.push(0); points.push(1024) points.push(49); points.push(0) points.push(49); return points;}function create(){ game.physics.gravity.y = 15; bg = game.add.tileSprite(0, 0, 1024, 512, 'background'); bg.body.allowGravity = false; ship = game.add.sprite(512, 100, 'ship'); ship.body.collideWorldBounds = false; ship.anchor.setTo(0.5, 0.5); ship.body.setPolygon(5, 5, 30, 5, 30, 35, 5, 35); var points = groundGenerator(); ground = game.add.sprite(0, 512 - 50, 'ground'); ground.body.setPolygon(points); ground.body.backgroundColor = '#111111'; ground.body.allowGravity = false; ground.body.immovable = true;}function collisionHandler(ship, ground){ console.log("ship landed"); isLanded = true; console.log(vSpeed); if (ship.angle != 0 || Math.abs(hSpeed) > 20 || vSpeed < -40) { ship.kill(); explosion = game.add.sprite(ship.body.x, ship.body.y, 'explosion'); setTimeout(function() {explosion.kill();}, 150); // explosion } else { resetPhysicsOnLanding(ship); } acceleration = 0;}
  10. Hi, I am creating a character using different sprite parts and parenting it to a single sprite. //Parent spritethis.torso = group.create(0,0,actorType + '_body');this.torso.anchor.setTo(0.5, 0);//Child Sprite this.frontFoot = game.add.sprite(0,0, actorType + '_foot_front');this.frontFoot.anchor.setTo(0.5, 0);this.torso.addChild(this.frontFoot);I tried to enable the Physics body part of the parent sprite, Phaser.Physics.ARCADE);The result is that all child sprites have been given a body and started to drop. I just want the parent to drop itself and all child will just follow its parents. Can anyone explain further what is happening here? Any link or topics that might have discussed this?
  11. so i checked the latest commits and saw that there are now 3 physics systems available and 2 more to come.. wow.. i'm a little bit overwhelmed because i just learned phaser1.1.x and it seemed so easy to understand.. now i'm unsure what to do... therefore i have some questions: 1) if i want to make a typical platformer game with slanted, round, triangle or square tiles i guess i would use ninja for the physics between my objects and the tilemap - wrong? 2) if i also love the possibilities of p2 materials and i want to apply specific material options to one of my gameworld layers? am i able to do so? combine p2 materials with a ninja tilemap collision handler? 2.2) how do i apply something to a layer.. do i really have to circle through every single tile in the tilemap somehow or can't i just say.. layer.setMaterial() ? (i hope there is/willbe a function for that) 3) if i also want very specific collisionProcessHandler (jump through from below but land on platforms for example) can i do this with ninja or do i need to apply arcade physics to this tilemap layer then? 4) if i want to shoot my enemies and need a very simple arcade collisionCallback and also a specific collisionProcesshandler (if invisible do not collide but fly through) AND i want this enemy to collide with my tilemap tiles in a ninja way.. would this be possible? so all in all one question could sum it up: 5) am i supposed to chose A single physics system or are they interoperable ? 6) which physics systems are a good idea to use together and which ones are a very bad idea? 7) is sounds like a performance drop is inevitable when using p2 and ninja and arcade alltogehther -wrong? big thx for every answer!
  12. Hi, I just changed from 1.1.2 to 1.1.4 and i can't detect to collision side of my sprite. define("Play", ['Game', 'Holoboy'], function(Game, Holoboy) { var Play = function (){ = Game; this.holoboy;; this.layer; }; Play.prototype = { preload: function(){, 0, 'preloaderBackground'); }, create: function(){ this.holoboy = new Holoboy(0,0); ='map');'tiles');, 12); this.layer ='Calque de Tile 1'); }, update: function(){ this.holoboy.move();, this.layer); console.log(this.holoboy.sprite.body.touching); } } return Play; });My console.log(this.holoboy.sprite.body.touching); always alert me Object {none: true, up: false, down: false, left: false, right: falseā€¦} My holoboy object : My controllable object : The collision works well by the way. My character can jump on the tiles and he is stopped by them. What's wrong with my code? Thank you
  13. Hi guys, I have a strange problem. I've created a tilemap and player sprite. Collision between them works, but I need to know on which side of the player the colission happend. I've llocked through the examples and the docs and found .body.touching.X. So, this was exactly what I was looking for. But it doesn't work. Down,up,left and right are always false. Even in the moment when the player sprite touches a collision tile. The variable "none" of body.touching is always true. Any help would be great! Here's some code I'm using: function create() { // setting global gravity to 100 game.physics.gravity.y = 100; cursors = game.input.keyboard.createCursorKeys(); // adding the tilemap created with Tiled map = game.add.tilemap('current_level'); map.addTilesetImage('tiles', 'tiles'); // the gray tiles shall be responsible for collisions, check the tiles.png, the first one is the gray one map.setCollisionBetween(0, 1); // loading the layer from the tilemap, the layer name got defines in the Tiled editor map_layer = map.createLayer('Level'); map_layer.resizeWorld(); map_layer.debug = true; // show the bounding boxes for collisions // creating and adding the player sprite player = game.add.sprite(50,400,"player"); player.body.collideWorldBounds = true; // don't move out of the screen player.body.immovable = true; // no bouncing or other fancy physics stuff for the player player.body.linearDamping = 0; // the button to change the gravity button = game.add.button(250,400, 'gravity_button', action_flip_gravity, this, 2, 1, 0); button.body.allowGravity = false; } function update(){ // update collision checks for the player an the map every update cycle game.physics.collide(player, map_layer,collide_player_with_world);}function collide_player_with_world(player,map_layer){ console.log("collide_player_with_world none: " + player.body.touching.none); if(!player.body.touching.down && game.physics.gravity.y > 0){ console.log("collide_player_with_world down: " + player.body.touching.down); move_to_x = null; move_direction = 0; player.body.velocity.setTo(0,0); } }
  14. Hello, I'm pretty new to Babylon.js (almost a week for now), it was okay until I started to ask more and more of it. I searched for answers a lot, in Google and here, on forums, but no success. So, here's some questions of mine that I can't deal with: [1] How can I set up 32x32 pixels image to stay sharp on some pretty big cube mesh? I found 'noMipmap' parameter for 'BABYLON.Texture', but I don't understand how to use it, what's 'type' thing? I need something like nearest neighbour thing. Any thoughts? [EDIT]: So, 'noMipmap' and 'invertY' both use 'true' or 'false', right? I found Babylon.js documentation here and it says 'type', not 'boolean', I'm confused (maybe I just don't know some simple things). 'noMipmap' works if things getting smaller, but not bigger or it works both ways, but uses exactly 'smooth' thing? [EDIT2]: I've set texture to 512x512 and I feel fine about it for now. "I'm a blurryful!" .[-^o ^ - . .], [2] How to apply texture to chosen side (polygon) of mesh (box) only? As far as I know I can use Blender for that, but is there a thing that I can use while using code only? [EDIT]: I found out that I can use that one (not tried yet though): materialName.reflectionTexture = new BABYLON.CubeTexture("folder/filename", scene);materialName.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;// filename_nx.png, filename_ny.png, filename_nz.png, filename_px.png, filename_py.png, filename_pz.png[3] How to get 'lookAt' method be instant instead of slowly rotate meshes to target? [EDIT]: I stopped pulling my hair off and just placed piggy sprite inside of mesh (just copied its position), also applied 1x1 alpha texture to the mesh, at least I've got almost the same result I wanted (mesh has physics). [EDIT2]: Just found .isVisible and set it to false instead of adding materials and set transparent texture for them. Removed '.setPhysicsState' for mesh and calculate stuff like some simple platformer now. Sprite checks its position through '.runRenderLoop' function. "Dusk is getting closer, oink!" [4] Is there any function or method I can use to calculate shadow using texture instead of mesh itself (shadow of sprite)? [5] How can I get rid of white outline around texture which has 'hasAlpha' set to 'true'? [6] Sometimes it takes too long to load textures (about 15s or more), any idea why? [7] How to send physics to sleep when its not used and if it stays calm and touches nothing except floor where it lays for a few? [8] How to tell mesh that has '.setPhysicsState' to check collision with mesh that doesn't has it (not .intersectsMesh though, but to react if first mesh has '.setPhysicsState' as well, while it doesn't)?
  15. Hi folks, I'm new to Phaser, seems like a nice framework so I decided to try it for recent Flappy Jam. However I cannot wrap my head around sprite vs group collision. I'm creating a rotated group (let's say 45 degrees) which consist of 2 sprites (lower/higher pipe parts). But that rotation of group cause player to collide directly with AABB bounding boxes generated around rotated sprites. How can I achieve desired collision directly on sprite within group? How can I switch from AABB to SAT based collisions? Please see attached image for better description of a problem.
  16. Hey, I'm new to forum and phaser.js. [uPDATE] I don't have anymore problem with my gravity, but I don't have idea how to show sprite on the circle, it renders circle on Jet. Also is it possible to change opacity of circle? I want to get transparent circle color. Thanks Source Code : var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'Jet Fly', { preload: preload, create: create, update: update, render: render });function preload() { game.load.image('arrow', 'img/jet.gif');}var circle;var sprite;var setGravityToPointXY = function(game,sprite,power, radiusLow,radiusHigh,pointX,pointY){ var pointXY = new Phaser.Point(pointX,pointY); var tempDistance = Phaser.Point.distance(sprite,pointXY); // console.log(tempDistance); if(tempDistance>radiusLow&&tempDistance<radiusHigh){ var rotation = game.physics.angleToXY(sprite,pointX,pointY); sprite.body.velocity.y += Math.round(Math.sin(rotation)*1000)/1000 * (power); sprite.body.velocity.x += Math.round(Math.cos(rotation)*1000)/1000 * (power); }};var getJetDegree = function(aX,aY){ return 90+180*(game.physics.angleToXY(new Phaser.Point(0,0),aX,aY)/Math.PI);};function create() { game.stage.backgroundColor = '#0072bc'; sprite = game.add.sprite(50, 200, 'arrow'); sprite.anchor.setTo(0.5, 0.5); sprite.angle = 90; sprite.body.velocity.x = 50; circle = new Phaser.Circle(400, 300,300); circle.alpha = game.math.clamp(circle.lifespan / 1000, 0, 1);}function update() { setGravityToPointXY(game,sprite,0.1,0,150,400,300);}function render() { game.debug.renderCircle(circle,'#cfffff');} Screenshoot :
  17. I'm new to phaser and really just trying to familiarize myself with it. I've got a sprite group moving across the screen from right to left and when it reaches certain locations I would like it to perform certain actions; for now I'm just having it log to the console. game.physics.collide(group, triggerWall, function(){ console.log('it hit the wall');}, null, this);The wall is an invisible sprite that 1px wide and 100% the height of the game. It logs to the console as expected (about 100x, due to the width of the group) The issue I'm having trouble with is there's a "jitter" when the group crosses the line. Each sprite in the group is moved a few pixels and then moves back. Heres how I've set up the sprites in the group: group =;for (var i = 0; i < 5; i++){ var sprite; sprite = group.create(x, y, 'block', 1); = 'block' + i; sprite.height = 30; sprite.width = 30; sprite.body.allowCollision = true; sprite.body.immovable = false;}and my "wall" triggerWall = game.add.sprite((, 1, 'barrier')); = 'triggerWall';triggerWall.scale.setTo(1,;triggerWall.body.immovable = true;triggerWall.visible = false;So I'm wondering how to avoid the "jitter", or if there's a better way to detect the location of a sprite/group besides using a collision.
  18. I'm trying to make a little game using physics, where the user pushes balls around. The balls are defined as Sprite extensions, like this: function Player(game, type) {, game,,, 'player') this.anchor.setTo(0.5, 0.5) this.type = type this.body.collideWorldBounds = true this.body.allowRotation = true this.body.bounce.setTo(0.6, 0.6) this.body.setCircle(50) this.body.angularDrag = 50 this.body.drag = 5 game.add.existing(this) } And the interaction is based on doing: this.players.getAt(0).body.velocity.x -= 10with every one of the directions, depending on the key pressed. It works, I can push elements around. But I'm facing an issue, I don't know it it's a bug or it's just expected to work like this and I'm missing something. The problem is that the elements overlap in some situations. For example, if I keep pressing the key, forcing the sprite against another one, it may finally "break" the collision boundary and overlap. Is there a solution for this? Is it a known issue? Thank you
  19. Hey Guys, I have having a bit of an odd issue with the collision physics, I have stacked 3 blocks onto of each other (after having them dropped from above) they are all part of the same group and I have them set to collide with themselves, however they seem to jitter about of the stop, almost like they are stuck in a mini bounce, however I have set bounce to 0 and I still seem to be getting this error, does anybody know why this is happening? BasicGame.Roll.prototype = { create: function () { var dice1 = Math.floor((Math.random()*6)+1); var dice2 = Math.floor((Math.random()*6)+1); var dice3 = Math.floor((Math.random()*6)+1); var diceImage; this.diceSet =; for(var i = 1; i <= 2; i++) { switch(i) { case 1: diceImage = dice1; break; case 2: diceImage = dice2; break; case 3: diceImage = dice3; break; } var dice = this.diceSet.create(100, -170*i, diceImage); dice.scale.setTo(2, 2); } this.diceSet.setAll('body.gravity.y', 1000); this.diceSet.setAll('body.bounce.y', 0); this.diceSet.setAll('body.minBounceVelocity', 0); this.add.sprite(0, 0, 'frame'); this.floor = this.add.sprite(0,, 'floor'); this.floor.body.immovable = true; }, update: function () { this.physics.collide(this.diceSet, this.diceSet); this.physics.collide(this.diceSet, this.floor); }Thanks in advance. Telash Edit: From what I can tell it appears to be an issue with the scaling.
  20. Hey guys, i'm fairly new to phaser, in-fact I am still mostly just modifying the tutoral star collection demo to see what I can do. I have successfully added a standard enemy which walks backwards and forwards on a set path, as well as a basic 3 life system, the problem I am having though is the generic parabolic knock back effect. Everything I try results in my player sprite either shooting off to the corner of the canvas or giving me some kind of weird zero gravity style knock back which looks plain odd. Does anybody have an example of how this works in phaser that they wouldn't mind sharing? (also if anyone knows anything about how to determine which direction the knock back should trigger that would also be great.) Thanks in advance guys
  21. Hi, there, I'm looking for a 3D physics library in JavaScript, which has kinda Kinematic Character Controller and Height Map(aka Height Field), like this video. I expect, player will: - not slip down on gentle slopes - slip down on steep slopes - not jump after though uphills - not slow down during ascending slopes - hit walls Dose anyone know it? Thanks,
  22. sur0x

    Character Dash

    Hi , First of all, I'm new to programming and creating games, so I'm trying to make my character dash some frames in X , they way I implemented it's kinda of teleporting the player. Could anyone help me to figure out how to do it smoothly? I'm planning to add a custom dash animation to the sprite, so far I'm using the default phaser character. Here's my piece of code: function dashLeft() { if (player.body.touching.down && player.body.facing == 2) { dashGauge = dashGauge-1 player.body.velocity.x += 1000; console.log(dashGauge) dashOut(); } } function dashRight() { if (player.body.touching.down && player.body.facing == 1) { dashGauge = dashGauge-1 player.body.velocity.x += -1000; console.log(dashGauge) dashOut(); } }I think - player.body.velocity.x += -1000; doesn't seem the best option for a smoothly movement Thank's in advance.
  23. Please tell me, how I can use P2.js physics in phaser framework? Whether there is an example of this? I have seen what p2 files included in sources framework? but I don't know how to call P2 physics in phaser. I would be very grateful for the help)
  24. I have a group object with a few independent parts, The character sprite, the players name hovering above, and a status object, which will likely be more sprites and text in a sub-group. How can I make this group act as one object? Like stopping the whole group with collideWorldBounds? Right now Im only able to stop the player sprite with body.collideWorldBounds = true, but the text just keeps on going right off the screen. There doesnt seem to be a way to set body properties on a group?