rich Posted January 14, 2014 Author Share Posted January 14, 2014 Thanks for all this feedback guys, I really really appreciate it WeaveMN - I agree re: cameraOffset and will see if I can't do away with it totally. Right now I'm working on setting the Body's "blocked" state. A body is set to be blocked in any of the 4 directions, for example if it's against the world bounds, or has hit a tile. However the blocked state was never checked in the physics collisions, meaning a sprite could push another sprite into a tile/bounds, even if only by a little bit, it would still make things judder. Right now I'm close to finishing this so that will never happen. Then I need to test some stacking sprites and high velocity stuff. Link to comment Share on other sites More sharing options...
jcs Posted January 14, 2014 Share Posted January 14, 2014 one more thing: Tilemap.putTile isn't correctly (re)setting the collision data for the tilemap. calculateFaces is being called, but that doesn't do everything necessary, apparently. I think this is happening only when changing to a tile that is NOT collide-able. The original setCollision call set faceX to true for all the tile's faces, and calculateFaces will only ever set it to false based on the tiles around it. so it remains collide-able even after changed. I'll see if I can get to the root of it and get a fix PR, since I'm halfway there already... Link to comment Share on other sites More sharing options...
jcs Posted January 15, 2014 Share Posted January 15, 2014 it looks like if I pass a Tile object to putTile, rather than an index, that this would work. but I believe an index ought to work properly as well. (the culprit is that the same Tile object is retained in memory and only the index is changed - so its collides property etc aren't updated. so my prior line of thinking was incorrect, this would happen going from collide-able to non-collide-able and vice versa) Link to comment Share on other sites More sharing options...
jcs Posted January 15, 2014 Share Posted January 15, 2014 Rich - because the list of 'collide-able' tile indices is not saved anywhere, there's no quick way to make putTile correctly set the 'collides' property if it is given a tile index. the work-around, as stated above, is to pass a complete Tile object rather than an index, so this isn't blocking any functionality, it just works in a counter-intuitive fashion. I believe the fix would require keeping the list of 'collide-able' tiles (or an exclusion list). easily done, but I don't want to post a PR with that unless you think it's appropriate. for now I'll pass the full Tile object in my code cheers Link to comment Share on other sites More sharing options...
rich Posted January 15, 2014 Author Share Posted January 15, 2014 Thanks jcs, I'll have a look once I'm done with this bit of code. Link to comment Share on other sites More sharing options...
rafaholiveira Posted January 15, 2014 Share Posted January 15, 2014 Phaser.Tileset.getTile uses this.tiles[index], but there is no variable tiles in Tileset. I was trying to set the collision of the faces of the tiles, but Tileset.getTile shows undefined for tiles. Link to comment Share on other sites More sharing options...
Mefteg Posted January 15, 2014 Share Posted January 15, 2014 Hello, Great work with this new version !Tilemaps fix all problems I had (black borders when moving the camera, troubles with collisions).However, I have an issue with the "follow" method of camera. I've created a "deadzone" but the camera moves too slowly and my player goes out of viewport. You can see that here : http://folia-game.herokuapp.com/ Here is my code to ask the camera to follow the player (in level.js) :// tell the camera to follow the playerthis.game.camera.follow(this.player.sprite);// give the camera a deadzone (to don't move all the time)this.game.camera.deadzone = new Phaser.Rectangle( this.game.camera.width * 0.3, this.game.camera.height * 0.3, this.game.camera.width * 0.4, this.game.camera.height * 0.4);Good luck ! Link to comment Share on other sites More sharing options...
rich Posted January 15, 2014 Author Share Posted January 15, 2014 Yes I need to remove that, well spotted. Will do so now. You don't set collision on tiles like that any more. Link to comment Share on other sites More sharing options...
jpdev Posted January 15, 2014 Share Posted January 15, 2014 I use "Phaser.Camera.FOLLOW_PLATFORMER" when setting the camera to follow the player sprite, this runs into the same bug as mentioned by Mefteg in #32.(I guess internally it will just set a deadzone.. well just checked, yes it does.) Mefteg 1 Link to comment Share on other sites More sharing options...
jpdev Posted January 15, 2014 Share Posted January 15, 2014 Another small thing I can report (don't know if it's already mentioned) Using gravity + velocity to jump the player and coliding with a tilemap (as the ground) and no bounce the following happens: Issue: when landing after a jump the touching.down jitters for a few frames (from true to false and back again alternating everytime update() is called). This is highly visible if you (as in my case) you change the frame of the player based on the body.touching.down variable. Link to comment Share on other sites More sharing options...
jcs Posted January 15, 2014 Share Posted January 15, 2014 Rich -FYI, in case you hadn't noticed, as of commit abdaaa0010afde2f50b3ab927365a8f1907cac52 sprites (in a side-scroller with gravity) slowly sink through the tilemap (and right off the map if they are not constrained to the world bounds) cheers Link to comment Share on other sites More sharing options...
rich Posted January 15, 2014 Author Share Posted January 15, 2014 Yeah, bare with me, lots of changes going on right now. Link to comment Share on other sites More sharing options...
Zeterain Posted January 15, 2014 Share Posted January 15, 2014 All is well as far as my game was concerned. I had to change the onStartCallbacks and onCompleteCalbacks, but I know that was intentional and was a quick fix. (Literally just a replace "Callback" -> ".add") Link to comment Share on other sites More sharing options...
WaltDjr Posted January 16, 2014 Share Posted January 16, 2014 I just downloaded the dev branch a few minutes ago and I'm having a lot of problems just getting the tilemap examples working, including starstruck. The sprite will bounce on each "level" on the way down but still ends up on world bounds and none of the horizontal walls will collide. I also noticed in the sci fly the emitter's particle burst collides with the layer correctly but the sprite still doesn't. Is this something that you are aware of and are still working on? I've tried it on Chrome as well as an iPad. WaltDjr Link to comment Share on other sites More sharing options...
Shadow20 Posted January 16, 2014 Share Posted January 16, 2014 I started using the dev branch as well but i am having issues with the typescript definitions when i compile. I attached the image below with the errors. Thanks in advance. Link to comment Share on other sites More sharing options...
@99golems Posted January 17, 2014 Share Posted January 17, 2014 **this has been solved, and was a product of my not using setCollisionBetween() correctly. Thanks jcs!** here's a weird one regarding tilemap collisions. I only get collisions between sprites and a tilemap layer to work if i set the collision layer as the very last layer in Tiled. If i set my collision layer as anything but the last layer in the Tiled editior then collision in Phaser won't work. pic of what i'm talking about ("foreground" is the layer i'm doing collision with): Here's what my create() and update() bits look like, and how i'm doing collision:create: function(){ this.map = game.add.tilemap(this.mapName); this.map.addTilesetImage('grass70x70'); this.layerSky = this.map.createLayer('sky'); this.layerFar01 = this.map.createLayer('far01'); this.layerForeground = this.map.createLayer('foreground'); this.map.setCollisionBetween(0, 36);}update: function(){ game.physics.collide(this.player,this.layerForeground);}I haven't looked into it because i can fix it by messing with the order in Tiled, but it's just a little annoying having my background layers in front of my foreground layers in Tiled. Link to comment Share on other sites More sharing options...
@99golems Posted January 17, 2014 Share Posted January 17, 2014 Here's another one about timers and events. If i set an event to repeat via game.time.events.repeat(), and in the same update cycle i also set an event to fire only once via game.time.events.add() and the callback function for the game.time.events.add() contains another game.time.events.add() then it stops the repeat from repeating and only happens once. for example inside a chrome dev console you can verify via the following:doNothing = function(){};doSomething = function(){ game.time.events.add(300, function(){console.log("do something once");},this); }//THIS ONE HERE WORKS (executed on the same line in the chrome dev console):game.time.events.repeat(300,10,function(){console.log("repeating 10 times")}, this); game.time.events.add(300,doNothing, this);//THIS ONE HERE DOES NOT REPEAT MORE THAN ONCE:game.time.events.repeat(300,10,function(){console.log("repeating 10 times")}, this); game.time.events.add(300, doSomething, this); I did not play with the durations, and just kept it at 300 for arbitrariness. Link to comment Share on other sites More sharing options...
jcs Posted January 18, 2014 Share Posted January 18, 2014 @99golems: TileMap.setCollisionBetween() takes an argument for the layer that you want to set collision on. If you don't specify one, it defaults to the current layer and thus you get the behaviour you're seeing. @99golems 1 Link to comment Share on other sites More sharing options...
legnox Posted January 18, 2014 Share Posted January 18, 2014 This might seem silly but, have you tried changing this create: function(){ this.layerSky = this.map.createLayer('sky'); this.layerFar01 = this.map.createLayer('far01'); this.layerForeground = this.map.createLayer('foreground');to this create: function(){ this.layerSky = this.map.createLayer('sky'); this.layerForeground = this.map.createLayer('foreground'); this.layerFar01 = this.map.createLayer('far01'); Link to comment Share on other sites More sharing options...
Benjans Posted January 18, 2014 Share Posted January 18, 2014 Hi, The 1.1.4 version solved many problems and improved my game, thank you so much (one more time) I just have a big problem to load tilemaps, maybe I'm doing it wrong (many people says that it's ok for them), but I can't see where.You can check an example here : http://benjans.altervista.org/It's very basic, and i've got this error :Phaser.Cache.getTilemapData: Invalid key: "0" No tiles are displayed (and according to the network pannel of my debug console, the JSON file and the tileset are not loaded)...Do you see what i'm doing wrong ? Thank you ! Link to comment Share on other sites More sharing options...
rich Posted January 18, 2014 Author Share Posted January 18, 2014 Benjans: The format of your load.tilemap call is slightly wrong. You've got:game.load.tilemap('world', 'tileset.png', 'map.json', null, Phaser.Tilemap.TILED_JSON);But the actual method signature is:game.load.tilemap('map', 'assets/tilemaps/maps/features_test.json', null, Phaser.Tilemap.TILED_JSON); Benjans 1 Link to comment Share on other sites More sharing options...
Benjans Posted January 18, 2014 Share Posted January 18, 2014 You're right and it works now, thank you.The strange thing is that informations (like tilesize) are now read in the tiled json file.Is there a way to specify it in the code? Link to comment Share on other sites More sharing options...
rich Posted January 20, 2014 Author Share Posted January 20, 2014 No it has to be defined in the json file now, because you can have multiple tile sizes per layer of a single map, so it's no longer something that can be set in a parameter. Link to comment Share on other sites More sharing options...
rich Posted January 20, 2014 Author Share Posted January 20, 2014 Right.. last week was a bit hectic finishing off some client projects, but I've a pretty clear run in Phaser this week - so time to battle on with my last physics updates and go through the bugs / feedback reported here and on github and get 1.1.4 finally out the door. Link to comment Share on other sites More sharing options...
Benjans Posted January 20, 2014 Share Posted January 20, 2014 I found a small bug (trying to create the interfaces for my game), it was already here in the previous version.When you put several texts on the stage and try to fix it to camera, X and Y properties are not respected, and they are put on 0,0.You can check it here : http://benjans.altervista.org/ This is my code :var style = { font: "12px Arial", fill: "#ffffff" };var t1 = game.add.text(10, 10, 'This is the first sentence', style);t1.fixedToCamera = true;var t2 = game.add.text(100, 100, 'This is the second sentence', style);t2.fixedToCamera = true; Link to comment Share on other sites More sharing options...
Recommended Posts