valueerror

Members
  • Content Count

    1096
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by valueerror

  1. thank you very much for this explanaiton! i'd suggest Phaser3 as a name.. just because the name stands for a good and easy to use js gameframework.. a good brand should stick to it's name and logo ... have a look at this... they know why they are doing this ^^
  2. http://test.xapient.net/circleworld/ like this for example.. i used 4 polygons to round the edges and tiled map edior to paint those polygons...
  3. of course.. you just should keep track of your constraint.. usually i store the constraint directly on one of the constrained objects.. somesprite.constraint = game.physics.p2.createRevoluteConstraint(somesprite.body, [0,0], someothersprite.body, [0,0], 10000);then i delete it with: game.physics.p2.removeConstraint(somesprite.constraint);somesprite.constraint = null;you could also clear ALL constraints at once: function clearAllConstraints(){ var allConstraints = game.physics.p2.world.constraints.splice(0,game.physics.p2.world.constraints.length); if (allConstraints.length > 0){ for (i=0; i<=allConstraints.length; i++){ game.physics.p2.removeConstraint(allConstraints[i]);} }}note that i use a workaround to get all constraints because the last time i checked the "getConstraints()" function returned "undefined" (i already reported the bug so it's probably fixed by now)
  4. every p2 body gets a rectangular shape in the size of the image first.. until you call somesprite.body.setCircle(20); for example.. then the first shape gets replaced with a circle ;-) yanifska's way is perfect if you want to change the physics body anyway.. that way you can always access the playershape directly by its representation "playersensor" (for example) to acces the first shape of any body you could also do the following: somesprite.body.data.shapes[0].sensor = true;as you can see all shapes are stored in the body.data.shapes[] array
  5. hehe.. maybe.. btw. i posted this example because i used sensors of course.. but this is by far not the best way to accomplish what i actually wanted to do there.. (the jumpthrough platform) i managed to get it to work with a totally different approach... (just in case someone needs it ) http://www.html5gamedevs.com/topic/6148-the-moving-jumpthrough-platform-sum-up-thread-help-very-much-appreciated/?p=36930
  6. just configure the bullets to act as sensor.... they will not trigger a collision response but still report the collision.. so you could then change the health of the enemy and destroy the bullet but no physics response will occur !
  7. well.. collisiongroups shouldn't be a problem in general unless you would like to have different collisiongroups for different shapes... (what would be great but i guess that's just not possible right now - correct me if i'm wrong please) the function that is called on contact (either through a collisiongroup callback or an onbegincontact event) has to figure out which shape of the body reported the contact and then act on it accordingly.. should work!
  8. http://test.xapient.net/phaser/ALL/moving-jumpthrough-platform-2.html this is one of my first experiments to get jumpthrough platforms to work.. i used two sensors.. the above one disables collision on contact and the lower one enables it... maybe you could read the code and find out what you want ?
  9. if you want to create a "dust trail" particle emmiters are probably not such a bad idea.. you can define a particle emitter flow, give it a gravity, set it to scale over time and decrease the alpha value.. that way you will easily create something that looks like the smoke coming out of a combustion engine..
  10. for vertical walls i did the same thing.. i used a slightly altered version of the "checkifcanjump" function to figure out if the player is touchingLeft or touchingRight and if so i canceld the movement.. BUT.. this function would probably also prohibit climbing 45deg hills..
  11. ah.. ok thx.. i think i understand if the camera starts to pan it probably reached it's bounds and tries to stay within them ?! you could try.. game.camera.bounds = null; just to find out if the bounds are the reason? and if you decide to put up an example on the sandbox i'l definitely give it a try
  12. oh.. and another thing.. the easiest way of all ways to do this is to just zoom to the current center of the camera.. do not change the camera position at all.. the user can position the wanted object manually into the center of the curren view and just zoom in and then move the camera manually again if the wanted object is not exactly there.. that's totally usable and reliable
  13. oke.. some thoughts: first of all.. it shakes? there is easing activated in the current code so the zooming motion is smooth - this leads to a little overlap.. the camera should reposition itself but the easing function isn't quite at the target scale position.. so the easing is going to finish and afterwards the camera is repositioned.. it's way better with pinch to zoom but the only way (or better the easiest way) you can get rid of this is by removing the easing. set easing to 1 and this "shaking" (i believe i figured out what you mean by that) is gone.. # that leads me to the first thought: don't use easing and definitely don't use tweens! this just delays the userinput and leads to situations where the user triggers an action but the tween is still running.. also your functions will have to wait for the tween to finish or deal with a constantly changing variable.. further you will create a hundred tweens in a second with your mouswheel function and every tween will try to do it's part.. what if the user suddenly wants to scroll out but the scroll-in tween is still running? what if the second tween is started but the first is still running? and btw. because you are not reusing your tweens but creating new ones the garbage collegtor will have a lot of work to do - but that's probably a problem for the future # use: game.camera.view.centerX and you can get rid of your setCenter() function # basically you are centering the object all the time into the center of the camera by moving the object.. this seems to be very problematic.. what if the object is moving on its own? what if there are a hundred objects.. instead try to center the camera over the object(s) - your current code seems to try something completely different than just zoom in or out of your map. # instead of scaling the world you should think of scaling a group.. that way you can define a seperate group that will not zoom (for the UI for example) # what about creating a jsfiddle or a phaser sandbox with a working example where everyone can try your stuff and test with real code? BTW. if you remove the touchzoom from my example and add the necessary code to your example to compensate for the scaling factor there will be no difference in complexity ;-) but it's always a good thing to write your own solution - a solution you fully understand !
  14. @icp: this doesn't exactly answer the question.. i think boolean already figured out how to make them collide but is wondering why i have to set bodyA to collide with bodyB and vice versa.. if A collides with B the logical outcome would be that B also collides with A - so why the redundance.. IMHO the best approach would be to set it independently from the bodies like. phaser.pyhysics.p2.setCollisions(ArrayA, ArrayB); //pseudocode !! all collisiongroups in arrayA should collide with all collisiongroups in arrayB)
  15. http://jsfiddle.net/valueerror/pdx0px0w/ working code zoom in/out with mousewheel (it will zoom to the pointer) or with pinch2zoom (it will zoom to the center between your fingers)
  16. well sorry.. as i already wrote twice the array "polyline_bodies" already contains the physics bodies (hence the name) the is no property body on a p2 body.. there just isn't ! whatever you are doing you are doing something different.. if your code works than only if your array contains sprites.. sprites have a body property which has a sprite property (recursive) in that case you should be able to call destroy() right away "polyline_bodies.destroy()" and it should work.. my question is: i'm calling destroy() on a p2 physics body and it isn't working.. instead i get this weird error message from above.. this only happens on p2 bodies that are polygons created from a tilemap.. the only difference between a body that i can destroy and this one is that the first one also has a sprite.. the undestroyable body has sprite:null
  17. valueerror

    Infinite game

    thx.. but it seems it is not possible to move a tilemap layer.. i managed to move it but it's cropped at the camera-view so its just the first 768 pixel that are moved.. the rest is invisible..
  18. thx for your thoughts but the array already contains the physics bodies.. therefore .body on a body will definitely fail. and those polygons have no sprite.. so i'm unable to access the sprite.kill or sprite.destroy methods..
  19. valueerror

    Infinite game

    i tried preloading the map 1000 px before the worldend and then just switch the alpha state BUT id didn't help.. moving everything to preRender() made it a little bit better but the glitch stays.. it is actually not caused by the map change but by the repositioning of the player.. so the best way would still be to have a camera without bounds (so it will scroll forever) and just put the new map at the end of the last map.. but it seems that i can not postion a layer relative to another ? or can i ? newmap.x = oldmap.width; // that would be cool
  20. this is how the array that contains all the physicsbodies is created polyline_bodies = game.physics.p2.convertCollisionObjects(supermap,"polygons");i can then cycle over all bodies and flawlessly set collisiongroups, materials and so on.. but if i want to cycle through this array and kill the physics bodies in it for (i=0; i<polyline_bodies.length; i++){ polyline_bodies[i].destroy()}i get the following weird error: Uncaught TypeError: Cannot set property 'body' of nullc.Physics.P2.Body.destroy @ phaser.min.js:23level0.update @ game.js:616how can i destroy the bodies in there.. thank you !
  21. valueerror

    Infinite game

    well i found a solution for my 2 - directional game.. (only east/west) every tilemap has the exact same size.. (200x20 tiles) 32 tiles match the cameraview (32*24= 768) that's the width of my camera every tilemap repeats the last 32 tiles from the former tilemap.. that way i can check the playerposition and if the player has reached the last part of the map (the moment where the camera wouldn't follow because the player is at the "worlds end" ) i kick the player.x coordinate back to the beginning of the map - kill the whole map and replace it with the next map.. i also store the current number of the map and if the last map is loaded it will then load the first map again at it's end.. that way i have a working worldwrap implemented it's definitely not perfect and i can see a really small glitch if i'm careful (as if there were 58 normal frames and 2 white frames) i thought i could build on this.. probably load the next map already 100px before that certain point and only change the visibility state.. that way the glitch should be gone.. unfortunately i have no idea how you would implement this in a 4 way map or even 8 ways
  22. valueerror

    Infinite game

    stumbling across the very same problem.. did you solve it ? if so.. please show us the way to go
  23. this is a help forum.. this also means that if you found a solution to your own problem you may want to post it to help others who find your post... your problem actually is that you add the bitmap text as child to a sprite at 0,0 a normal sprite has it's anchor in the upper left corner.. positioning a sprite as child at 0,0 will also be in the upper left corner.. changing the anchor of the text will only move it relative to the upper left corner... imho you should also change the anchor of the first sprite
  24. oh.. and funny thing.. someone discovered a "cheat" in my game to get infinite moves.. something i didn't program (at least not on purpose) i decided to NOT fix it for now because it only helps in some levels and i think it's cool that they "hacked" my code with gestures ^^
  25. well.. they work.. that's all i can say.. because no one bought the "no-ads-feature" but i tried with two accounts that are registered as testaccounts and completed a free purchase which - obviously - disabled the ads in the game for those users.. i tried to program the ads into my game in a very unintrusive way.. one fullscreen ad in the menu and a banner ad at the bottom of the finish screen... so they probably don't hurt enough make the purchase.. also i have only 90 installs.. that's not really a lot