rich Posted February 18, 2014 Author Share Posted February 18, 2014 4) Yes that was me testing the difference between applying velocity vs. force, sorry - will put it back again 5) Physics coordinate systems are inversed from the 'screen', so in physics everything starts bottom left and goes up, and is measured in meters. This is why all values are wrapped with px2p or p2px to translate the values around from both meters to pixels and the correct orientation. If you don't tweak p2 values directly it should be ok. Not sure re: the phaser.min file - might just have the wrong header on it. Your comment about a character 'sticking' to the side of another when velocity is applied sounds normal to me. Assuming the velocity is high enough to compensate for gravity that is. Right now I've got polyline parsing from Tiled data working which is pretty sweet. Just trying something with tile to body conversion now too, then will do another push. Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Author Share Posted February 18, 2014 Just played your Mario demo and I see what you mean about the sticking, but I'm pretty certain that's just down to the Material applied to the bodies (I've not yet Phaserified p2 materials, so they use the default which isn't great for platformers). Link to comment Share on other sites More sharing options...
valueerror Posted February 18, 2014 Share Posted February 18, 2014 hello rich.. i just saw that you added something about materials.. i can't wait to make ice plattforms with almost no friction.. i wonder how to use this? (btw. mario does not only stick to the sides of a plattform, he also sticks to the worldbounds(left/right) i have some more questions if you don't mind.. (if for my questions/problems to solve itself i only have to wait until you release phaser 1.2 - please say it and i'll give it all the time it needs ) 1) player.body.adjustCenterOfMass(); i need to set this, otherwise my player sinks into rotated objects.. but now it hovers over them .. normal? 2) is it already possible to somehow check if the player has hit something or rans into something? i miss the "touching.left/right" part.. 3) lifespan is a usefull method to make things disappear.. is is possible to do something with those objects right before the die (little animation.. scale.. something like that) 4) enemies.forEachAlive(moveAliveEnemy,this); the function moveAiveEnemy is not called anymore.. is there a substitute for something like this? 5) if body.mass=0 why can't i move them anymore.. it makes sense with static=true.. but mass=0 should let them float around or am i wrong?6) preload bar seems broken in the latest git pull (from yesterday) i just get the green rectangle btw. it's really nice how my fireballs roll down on rotated plattforms .. it's a lot of fun to play with and learn phaser Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Author Share Posted February 18, 2014 1) Depends entirely on your shapes, where they are positioned, etc. 2) Yes soon, the events for it are added to World, but not hooked in yet. 3) You could listen for Sprite.events.onKilled and then do something, but it'd be up to you to reset exists/visible first maybe. 4) Test case please 5) Something with a mass of zero is static in p2, if you just need a really tiny mass try 0.1. 6) My test is working, so will need example please (maybe breaks under certain situations like sprite from an atlas not a image, etc). re: Materials - look at the examples/wip/platforms.js demo for examples of how to create Materials and ContactMaterials and assign them to objects and the world bounds. Link to comment Share on other sites More sharing options...
Lonan Posted February 18, 2014 Share Posted February 18, 2014 Loving the latest commit! I'm trying to wrap my head around the materials at the moment and have some questions:Can you use a collision between objects with certain materials to trigger a function? How would you do that?Is there a way to let 2 sprites overlap and then give friction based on their materials?Another question: How would I go about currently adding gravity to individual game objects? Example: A few small planets that has their own gravity in a platformer. Thx Rich! Really appreciate all the work you put in. Every night I get home it's like opening a Christmas present when I check your progress. Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Author Share Posted February 18, 2014 You wouldn't use materials to trigger functions, nope. A Body consists of 1 or more shapes, and shape in that body can have 1 material. So for example imagine you had a 4x4 truck with a chassis and 2 wheels. You would want the wheels to have a pretty high degree of friction with the ground, so you could create a 'Rubber' Material for the wheels and a 'Ground' material. Then you combine the two into a ContactMaterial and this is where you set the properties like friction, restitution, surfaceVelocity, etc. When the simulation sees Rubber and Ground shapes colliding it applies the friction (etc) that you set in that specific ContactMaterial. This way you could assign the same 'rubber' material to all wheels of all cars/trucks in the same game. Equally you could create an Ice Material for bits of ground covered in ice - so you'd combine the Ice Material and the Rubber material into a new ContactMaterial that has a really low level of friction, as if driving on ice. I agree it's a bit different to get your head around than Phaser 1.1, but it's a much more flexible / powerful system jerome 1 Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Author Share Posted February 18, 2014 Missed the bit about Gravity - currently Bodies can't have their own gravity, but it's on the to do list. When I push up the work on Collision Groups then you'll see how to define callbacks, etc when bodies collide. Link to comment Share on other sites More sharing options...
valueerror Posted February 18, 2014 Share Posted February 18, 2014 ad 3) i thought at something like a beforediecollbackfunction.. but without this it's probably easier to start a well timed tween before the object disappears.. ad 4) sorry.. i found out that it works as expected but forgot to delete point nr4. ad 5) so i gave it mass 0.1 .. even 0.001 and it still moves down to the ground.. it only moves faster to the left now.. i wan't to create something that just flys through my game world.. from x=800 to x=0 without changing y due to gravity.. http://test.xapient.net/phaser/index2.html (EDIT: so when individual gravity arrives this problem will also be solved ) ad 6) i'll give it another try and (if unsuccessfull) post an example ad re cool thx.. i'll give it a shot Link to comment Share on other sites More sharing options...
Lonan Posted February 18, 2014 Share Posted February 18, 2014 Ok, that makes sense. Thx for the reply. Looking forward to the Collision Groups. Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Author Share Posted February 18, 2014 ad 5) so i gave it mass 0.1 .. even 0.001 and it still moves down to the ground.. it only moves faster to the left now.. i wan't to create something that just flys through my game world.. from x=800 to x=0 without changing y due to gravity.. http://test.xapient.net/phaser/index2.html (EDIT: so when individual gravity arrives this problem will also be solved ) Yes gravity will always effect an object regardless of mass. Right now you'd need to disable world gravity and apply a local velocity instead. BTW ContactMaterials will solve your 'wall sticking' problem entirely Link to comment Share on other sites More sharing options...
valueerror Posted February 19, 2014 Share Posted February 19, 2014 thx rich.. i hope i'll find some time to look into materials tomorrow.. as for the "moving an object from right to left in a world with gravity without changing y" part.. i found a surprisingly easy solution.. bullet.body.mass=0; and in the update function bullet.body.x -= 2; so it's static AND moves to the left another thing maybe worth mentioning.. there is something i already found out when programming with processing.js so maybe this is a problem with webbrowsers, graphics drivers and canvas and has nothing to do with phaser.. but what do i know ^^ chromium browser (at least on linux) slows down when i apply a css box-shadow to the div around the canvas... firefox doesn't seem to suffer from this problem... BUT firefox (27) is extreeeeemly slow when using webgl.. so i set up the game with Phaser.CANVAS and firefox is as fast as chrome again.. even faster... (fast or slow is somehow mesurable in my testcase because the cannons live only for 6 seconds.. with box shadow they die after the 3rd quarter of the game world .. without box shadow they leave the game world.. firefox with webgl is so slow.. the canons die in the first quarter.. Link to comment Share on other sites More sharing options...
rich Posted February 19, 2014 Author Share Posted February 19, 2014 Does it still collide when moving though? And yeah Firefox has issues with WebGL in certain situations. I mostly blame GPU drivers (or the way it uses them). And yeah, css box-shadows are a lovely way to kill perf sometimes Link to comment Share on other sites More sharing options...
valueerror Posted February 19, 2014 Share Posted February 19, 2014 it doesn't collide with other elements with mass=0 or static=true but it collides with my fireballs and my player.. @box-shadow.. i just can't see how a box shadow drawn around the canvas that is only drawn once can affect performance inside the canvas.. okay.. i CAN see it but it really shouldn't .. i just tried tweens... i wanted to create a paddle that moves around and mario can jump on it.. seems i can either create something to jump on or something that moves.. tweens on physicsEnabled bodies don't move anything (or am i doing something wrong?) Link to comment Share on other sites More sharing options...
jerome Posted February 19, 2014 Share Posted February 19, 2014 I guess when requestAnimationFrame method is called the browser is told to repaint the whole window (DOM element, CSS, etc) and shadows are costly to draw Link to comment Share on other sites More sharing options...
BunBunBun Posted February 19, 2014 Share Posted February 19, 2014 Rich, can you please look my topic http://www.html5gamedevs.com/topic/3967-113-paused-problem-with-android-galaxy-devices/ and see need to add something like that in phaser v2 or not. Link to comment Share on other sites More sharing options...
clark Posted February 20, 2014 Share Posted February 20, 2014 Hey Rich nice job on 1.2 I updated the typescript definitions again but this time having some problems. What is the relationship between PIXI and Phaser? This is a big question I know...But for example, lets consider Phaser.SpritePhaser.Sprite extends PIXI.DisplayObject?So as a result of that, Phaser.Sprite does not directly have an Alpha property. Or for example, Phaser.Group.parent returns a PIXI.DisplayObjectContainer So with regards to the definitions, what is the best way to handle this? Lets say a PIXI definition was available, I guess it is not as easy as simply merging the whole definition? I do not want to blindly copy all of the properties and methods from PIXI.DisplayObject into Phaser.Sprite (alpha is fine, but click (event) => void does need seem compatible with Phaser)?Does anyone know what I mean? Link to comment Share on other sites More sharing options...
rich Posted February 20, 2014 Author Share Posted February 20, 2014 Hey clark - yeah I know what you mean. v2 is a lot smarter about how it extends Pixi objects now, so requires a lot of properties and methods that already exist on the prototype, which means they aren't defined in the Phaser source at all. What would make most sense is to create a defs file that covered Pixi and we just place that at the top of the Phaser one. I know the pixi community would benefit from it too, so it'd make sense to offer it to them as well. However you're right, that does mean all the Pixi stuff like mouse events (which Phaser doesn't touch) or any of the Pixi loader files aren't needed. Actually here, I can give you a complete list of the Pixi files we don't use: <script src="$path/src/pixi/InteractionData.js"></script> <script src="$path/src/pixi/InteractionManager.js"></script> <script src="$path/src/pixi/loaders/AssetLoader.js"></script> <script src="$path/src/pixi/loaders/JsonLoader.js"></script> <script src="$path/src/pixi/loaders/AtlasLoader.js"></script> <script src="$path/src/pixi/loaders/SpriteSheetLoader.js"></script> <script src="$path/src/pixi/loaders/ImageLoader.js"></script> <script src="$path/src/pixi/loaders/BitmapFontLoader.js"></script> <script src="$path/src/pixi/loaders/SpineLoader.js"></script> <script src="$path/src/pixi/filters/AbstractFilter.js"></script> <script src="$path/src/pixi/filters/AlphaMaskFilter.js"></script> <script src="$path/src/pixi/filters/ColorMatrixFilter.js"></script> <script src="$path/src/pixi/filters/GrayFilter.js"></script> <script src="$path/src/pixi/filters/DisplacementFilter.js"></script> <script src="$path/src/pixi/filters/PixelateFilter.js"></script> <script src="$path/src/pixi/filters/BlurXFilter.js"></script> <script src="$path/src/pixi/filters/BlurYFilter.js"></script> <script src="$path/src/pixi/filters/BlurFilter.js"></script> <script src="$path/src/pixi/filters/InvertFilter.js"></script> <script src="$path/src/pixi/filters/SepiaFilter.js"></script> <script src="$path/src/pixi/filters/TwistFilter.js"></script> <script src="$path/src/pixi/filters/ColorStepFilter.js"></script> <script src="$path/src/pixi/filters/DotScreenFilter.js"></script> <script src="$path/src/pixi/filters/CrossHatchFilter.js"></script> <script src="$path/src/pixi/filters/RGBSplitFilter.js"></script> <script src="$path/src/pixi/extras/Spine.js"></script> <script src="$path/src/pixi/extras/Strip.js"></script> <script src="$path/src/pixi/extras/Rope.js"></script> <script src="$path/src/pixi/display/MovieClip.js"></script> <script src="$path/src/pixi/utils/Utils.js"></script> <script src="$path/src/pixi/core/Point.js"></script> <script src="$path/src/pixi/core/Rectangle.js"></script> <script src="$path/src/pixi/core/Circle.js"></script> <script src="$path/src/pixi/utils/Detector.js"></script>But essentially yes - if a Pixi defs file did exist then we could literally merge it with the Phaser one. Then all references would be correct. We actually need to do the same for p2 as well! But we could add @extends PIXI.DisplayObjectContainer for example, and it'd inherit the properties from that. You're right it could be confusing though as it'd inherit all the mouse events which don't exist. Arrgghh... there's no easy way Link to comment Share on other sites More sharing options...
valueerror Posted February 20, 2014 Share Posted February 20, 2014 @rich.. tried materials.. love it ! sticking to paddle is gone now when i apply friction=0 but then i have an ICE paddle with no friction at all.. the moment i apply friction=0.01 the sticking to the side is back.. so i have no clue how to create something where i wouldn't slide over like on a frozen lake and still don't stick on the sides .. you can try my "ice-pedals" against my "ground-pedals" here again http://test.xapient.net/phaser/ also i would like mario to slide down on a rotated paddle with normal "ground-material" i've created an additional "slide-material" and applied it to the rotated paddle but it would be better the friction would be reduced automagically with more rotation.. it should be reduced proportionally .. more degrees less friction or something similar.. then the problem with sticking to the side of objects would be solving itself.. oh.. and how can i do this again? (it's not working in the latest git pull but because i found it in the updated docs i thought it should be working)game.physics.collide(enemies, player) ; thank you very much!! Link to comment Share on other sites More sharing options...
clark Posted February 21, 2014 Share Posted February 21, 2014 Thanks Rich I am finding any knowledge about this really interesting. I decided to define the whole of PIXI first. (Not the PolyK, I do not get it). But it gave me an opportunity to merge Phaser. such as Phaser.Point extending PIXI.Point and all that good stuff.https://github.com/clark-stevenson/phaser/commit/45bdc5ed61d3f00e09fbd8d315996de7f24f7428I will work with this for a while and see how it goes. Its easier to comment out the stuff we do not need later if we need to than incrementally add stuff. Any advice or anything is welcome. Link to comment Share on other sites More sharing options...
rich Posted February 21, 2014 Author Share Posted February 21, 2014 @valueerror - friction isn't the only variable you've got to play with in materials, there are loads! some may be more suitable than others. surfaceVelocity for example. @clark - Nice This may help a bit: Phaser.Point, Rectangle, Circle, Ellipse and Polygon don't extend the Pixi versions, they replace them entirely. I alias Pixi.Point to Phaser.Point object for example. That should clear-up the issues with setTo. Link to comment Share on other sites More sharing options...
clark Posted February 21, 2014 Share Posted February 21, 2014 I am not sure what Alias means and I googled it I believe these are the only classes which directly extend PIXI in the those definitions. PointGroupGraphicsRenderTextureSpriteStageAnd just a question as I am interested. Given that PIXI.Point is x/y/clone() only. How come you decided to not override it? I would have (but I suck at ooa). Edited:I have turned illiterate in these past 3 days. Link to comment Share on other sites More sharing options...
rich Posted February 21, 2014 Author Share Posted February 21, 2014 Text, BitmapText and TileSprite extend PIXI classes too. Internally Pixi creates lots of Point objects. If Phaser.Point only extended Pixi.Point then ones created inside a DisplayObject for example would have different functions available to those made inside a Phaser object. It would just be a bit messy imho (like it is in 1.1, where I re-assign things like Sprite.scale to a Phaser Point), this allowed me to just keep things consistent and cut down on the amount of code needed. I could have extended PIXI.Point and added in all the things Phaser.Point has, but then we'd have differing namespaces in the docs and devs wouldn't know if they needed to make a Phaser Point or a Pixi Point or whatever. It just felt cleaner to me. clark 1 Link to comment Share on other sites More sharing options...
clark Posted February 21, 2014 Share Posted February 21, 2014 It sounds good to me!You were right, I added the Text/BitmapText/TileSprite and got rid of the Point inheritance.I will see how I get on with this and perhaps will get a chance at the weekend to create some better projects for testing. My current development for work uses only a small portion of Phaser's capability.Thanks for your help. Link to comment Share on other sites More sharing options...
rich Posted February 21, 2014 Author Share Posted February 21, 2014 What I'm doing today is putting all of the document stubs into classes like Sprite and Image from Pixi. Right now the docs don't include things like "alpha" because it's a Pixi level property, but sorting out all the doc stubs will fix that. This way you will know what properties are Phaser level and which are Pixi level hopefully. Link to comment Share on other sites More sharing options...
jpdev Posted February 21, 2014 Share Posted February 21, 2014 I have just seen the phaser labs 009 boxes.. Looks like you can do really fun stuff with the new physics system. I am really hoping for slanted tiles - since the slanted random boxes here work so good already clark 1 Link to comment Share on other sites More sharing options...
Recommended Posts