ceeed

Members
  • Content count

    7
  • Joined

  • Last visited

  1. found a solution player being the player sprite hitbox being the hitbox sprite hitbox.body.mass 0.00001; game.physics.p2.createLockConstraint(, hitbox, [0, 0], 0, 9999); i have some stuff set by default to all objects, so you might have to fiddle a bit to get it work. but this is way more fluid then the tracking method
  2. Hey guys, i'm trying to implement hitboxes with p2 physics. I all ready have a solution, but i find it kind of awkward. What i want to do is create a sprite, and attach multiple p2 bodies to it, the main body is the players hitbox which is just a normal polygon body. the other bodies are all set up as sensors so the don't mess with physics but still trigger the collide. I tried adding multiple sprites as childs with their own bodies, but that wont work. Has anyone done this before, or do i have to digg in deep? cheers ps: my current solution is creating sprites that are not linked together in any way, and than moving them all to the players position. laggy as hell
  3. I made a script for illustrator which can convert the shapes i draw in illustrator to polygons which i can load via json. My workflow looks like this atm. i create my map in photoshop or such, which a seperate layer for lights and shadows. then i export those thre files (background,shadows,lights) and import them in the game then i import the background image into illustrator, make one layer for the collision polygons, and one layer for the masks, export it and im done works like charm so far
  4. Hey guys, i figured it out. First i created a new group called silhouettes. Then i created a player sprite tinted it black, and added it to the children of my player sprite. After that i added the silhouette sprite to the silhouettes group. (this order is important) after that i created a polygon mask, and masked of the silhouettes group. player = game.add.sprite(100,100,'player'); silhouettes = game.add.group(); silhouette = game.add.sprite(0,0,'player'); silhouette.anchor.set(0,0); player.addChild(silhouette); silhouettes.add(silhouette); let maskData = game.cache.getPhysicsData('map_default_mask'); let graphics = game.add.graphics(0, 0); graphics.beginFill(0x000000); maskData.data.forEach((el) => { graphics.drawPolygon(el.shape); }); graphics.endFill(); game.groups.ghosts.mask = graphics; the result. http://www.giphy.com/gifs/3og0IwGoPYxW39mPzW
  5. My final goal will be mirroring the players sprite, tinting it in a color of my liking and mask it off with my foreground layer. If anyone has done this before, i would be glad to know how cheers
  6. I think i got it kind of working. http://www.giphy.com/gifs/xUPGczMscjA1etaPKg But i would rather have it in a blocked color than multiply. But i guess that's not worth the hussle. I will keep looking for a better solution, but for now this works. thx!
  7. Hey guys, Im making a top down game and i'm struggeling to find a solution, to show players behind an object. My goal was to have: 1. the background layer, which contains the map image 2. the player layer, which contains the player sprite and collisons 3. the foreground layer, which contains the objects which are over the player with this setup you wouldn't see the player behind the foreground layer so i want to add another layer which contains the player sprite tinted black or something but for that to work i need the foreground layer to be an alpha mask for the "silhouette" layer Any ideas how to archive this with a good performance?