Karma Octopus

Members
  • Content Count

    56
  • Joined

  • Last visited

Everything posted by Karma Octopus

  1. This is how I do tile layers in v3: // Grass var mapDataGrass = scene.cache.json.get('enviromentMap').layers[0].data; mapDataGrass.forEach(function (current, index, array) { mapDataGrass[index] = current - 1; }); tilemapGrass = scene.add.tilemap(mapDataGrass, 0, 0, tileWidth, tileHeight, mapWidth, mapHeight, 0, 'enviromentImg'); // Dirt var mapDataDirt = scene.cache.json.get('enviromentMap').layers[1].data; mapDataDirt.forEach(function (current, index, array) { mapDataDirt[index] = current - 1; }); tilemapDirt = scene.add.tilemap(mapDataDirt, 0, 0, tileWidth, tileHeight, mapWidth, mapHeight, 0, 'enviromentImg'); etc. I use the same tile image for all layers for performance reasons but in theory it should probably work to have different images for different layers, I haven't tested though so I don't know if that works. Just replace 'scene' with 'this' if that wasn't clear. (I reduce the index by one to make it the right one.) Let me know if you need more info to get it to work. Basically I think I'm just doing what you are doing but using dynamic tilemaps and shifting the indexing. But it does work fine for me.
  2. Very cool game. I love how it reminded me of games from my childhood. The enter button didn't work for me either.
  3. Really cool game! But if you press space the game scrolls up and away and you have to re-enter the web-page to restore it.
  4. Actually forget what I said above. I turns out that once you change the scale of the camera things start to get messed up real fast. Few things behave as expected. I thought it would be easy to add a minimap camera but it seems it not quite so. Not right now anyways, I'm sure it'll get fixed. Or maybe I just suck at phaser.
  5. I found 'body.pos' and 'body.vel' in Impact but I had to make my own get functions to actually get to them. I see now that maybe I didn't need to do that for 'body.vel' but I still don't think 'body.pos' is reachable. I believe adding this.pos = this.body.pos; to the constructor of ImpactBody.js will solve the access problem.
  6. var minimapCamera = this.cameras.add(512, 0, 512, 384); minimapCamera.zoom = 0.5; This creates a minimap camera at pos 512, 0 with a size of 512, 384. Then it sets the scale to be half that of your regular rendering. If your need to set other properties on the minimap camera you can do that just like how you set properties on your main camera. minimapCamera.setBounds(0, 0, mapWidth * tileWidth, mapHeight * tileHeight); minimapCamera.scrollX += 100; minimapCamera.x = 100; For example.
  7. I added some Impact physics to my test and it works very well. Some things that I needed though were getters for body position & velocity. I couldn't find any in the current code but I'm sure you'll add that later, if I didn't just miss it. In the mean time I just added some own temp stuff. Another thing I see is that debug boxes for bodies often overlaps when moving even if the bodies themselves don't overlap. I'm not sure if it's a bug or not. It looks like you maybe get the position data before the body has been pushed back after the collision.
  8. Thanks, changing filtering solved the outline problem! I think that tilemaps should default to nearest, just like how Tiled does it. That way you also don't get the outline issue I had. Also if you could add some constants like Texture.NEAREST and Texture.LINEAR that would be neat. Ex: t.setFilter(Texture.NEAREST), or something along those lines. Edit: I found Phaser.ScaleModes in the src.
  9. This is the wrong forum for your question since it relates to Phaser version 2. Try asking here instead: http://www.html5gamedevs.com/forum/14-phaser/
  10. I've added some tilemaps to my test and generally it works fine. But I'm getting some odd artifacts on transparent tiles. I suspects it's due to filtering issues. So I'm wondering if it is or will be possible to set the filter mode for a texture manually, at least in webgl mode? For example I would like to use Nearest neighbor filtering right now for all the images I have but in some games I would need to have some images use nearest and some use linear filtering for example. I have attached an image to explain the issue I have. The left side if from Tiled (properly rendered) and the right side from the v3 test. I use dynamic tilemaps but with static tilemaps the result is exactly the same. You can see the outline on the dirt and the rock. You also see that the texture is smoothed in phaser.
  11. I think this could be the best solution. The -1 is hidden but still there, very neat. I was a bit worried that loop and repeat are so alike that people would mix them up and not be sure which one does what. So it's probably best to only have one property for repetitions.
  12. If other popular tween libs use -1 it might be good to keep it. It's just a bit strange if you haven't used those libs before. I don't think it's a bad way to to it, I'm just used to -1 meaning 'unset'/'do not use'. Maybe keep repeat like it is now then and also add a 'loop' boolean that overrides repeat if set? That way the developer can choose which way feels most natural too them? Would be nice to know what other people think too.
  13. Yay! The new generateFrameNumbers works great, does exactly what I need it to. About -1 for repeat. After reading what you wrote it now makes sense how it works. But I think that many people will still find it strange and not understand it by just looking at some example code that someone wrote, just like what happened to me. This could be especially so for newer coders. I think it might be bit hard to grasp why it should be -1 without reading your text. I think it might be improved upon if the 'infinite repeat' is split apart from repeat. Like this: repeat: 0 - max repeats | choose no repeat or a limited number or repeats repeatForever: true/false | choose if to repeat forever -1 would have to be removed? as an option from repeat so you don't get (which would be unclear behavior): var config = { key: 'walkDown', repeat: -1, repeatForever: false }; I don't think this would affect how repeat works, just make it a bit more clear when you see examples like these: var config = { key: 'walkDown', repeat: 4 }; var config = { key: 'walkDown', repeatForever: true // pretty obvious what it does without having to look it up or repeatForever: 1 }; var config = { key: 'walkDown', repeat: 0 };
  14. First of all I'd like to say that Phaser 3 seems very nice, flexible and lightweight. I got it to work but I get two errors in the console when I create a new Phaser game (I use the newly released alpha version): Uncaught TypeError: Cannot read property 'createTexture' of null at new TextureSource (TextureSource.js:119) at new Texture (Texture.js:58) at TextureManager.create (TextureManager.js:252) at Image.image.onload (TextureManager.js:45) Edit: this is in Chrome. In FF the error is: TypeError: game.renderer is null TextureSource Texture create addBase64/image.onload This is the config: var config = { type: Phaser.WEBGL, width: 800, height: 600, backgroundColor: '#bfcc00', parent: 'content', scene: { preload: preload, create: create, update: update } }; It happens when this line is run: var game = new Phaser.Game(config); Though the errors doesn't seem to do anything. Now onto the animation part, I have two pieces of feedback. 1. I tried to create a simple animation from a spritesheet. It is a standard sheet with four walk animations, every animation has three frames which should be run like 0, 1, 2, 1 in a loop. My problem was that I cant find a way to make that happen. When I use generateFrameNumbers it runs frames 0, 1, 2, 0, 1, 2. Which is of course the intention. I use this code: var config = { key: 'walkDown', frames: this.anims.generateFrameNumbers('playerSheet', { start: 0, end: 2 }), frameRate: 8, repeat: -1 }; So what I would like to see is either a function so I can tell it to use frames [0, 1, 2, 1] or maybe an example on how to create some object that does that. I'm not so good at JS yet but I think that the frames property need such an object and that is what generateFrameNumbers return. Basically I just want to tell an animation what frames in a spritesheet to use, just like you can do in Phaser 2.x. Like this: this.player.animations.add('walkDown', [0, 1, 2, 1]); 2. To make the animation repeat I have to set repeat: -1. I found that to be very odd and unintuitive. I would have expected it to be 1 for repeat and 0 for non-repeat. Keep up the good work.
  15. I also had this problem on my Android device (since performance is so bad). What I finally found out was that if I decreased the gravity enough this didn't happen any more, so it could be a good idea to try lowering the gravity and see if that helps.
  16. It's a great looking game and the concept is really nice. The only thing I didn't like was that he moves sooo slowly across the line, at least on PC it's very hard to collect anything at the start, and the start is very important for a game or it will loose lots of players.
  17. I just tested it with the latest dev version and now it works as expected. Thanks Rich!
  18. I tried it with the latest version, sadly it doesn't work. It does work in 1.1.6, I'm not sure if that is of any help. I hope this issue can be fixed, I don't really need any advanced collision handling in this game so it would be totally overkill to use for example p2.
  19. I am using sprites inside a group as the ground and then I check collision of that group against the player sprite. Now the problem is that when the player sprite tries to move over the next sprite that the ground is made out of is just suddenly stops, like it has collided with and invisible object. In this image the player sprite will move just fine towards the right: But when it reaches the edge of the next floor sprite it stops moving: Even if the player now jumps up in the air it won't move to the right any more. This only occurs in 2.0 and up, I have tried it with the latest dev build too, The same thing works fine in 1.1.6. Here is some code to replicate it: private _player: Phaser.Sprite; private _collisionGroup: Phaser.Group; create() { this.game.physics.startSystem( Phaser.Physics.ARCADE ); this._collisionGroup = this.add.group(); this._collisionGroup.enableBody = true; this._collisionGroup.physicsBodyType = Phaser.Physics.ARCADE; for ( var i = 0; i < 15; i++ ) { var block: Phaser.Sprite = this._collisionGroup.create( i * 64, 300, 'collisionImage' ); block.body.immovable = true; block.body.allowGravity = false; } this._player = this.game.add.sprite( 200, 200, 'player', 0 ); this._player.anchor.setTo( 0.5, 0.5 ); this.game.physics.enable( this._player, Phaser.Physics.ARCADE ); this._player.body.velocity.x = 50; this.game.physics.arcade.gravity.y = 600; } update() { this.game.physics.arcade.collide( this._player, this._collisionGroup ); }
  20. Hey guys, I'm working on an endless runner but I have hit a big wall for now, I hope you can give me some hints. What I'm trying to do is to create different segments in Tiled and then randomly load those into the game as you are running I was thinking that the easiest way to do this would be to have three different containers in a row, each container would contain the data from one of the loaded segments. Then I would scroll the containers to the left and when the most left one was out of the screen I would move it to the right of the then most right one and repopulate it with data from another segment. In theory I thought this would be quite simple but it turns out it's not since I can't scroll a Tilemap and move it's position. Do you guys have any ideas? I would really like to use Tilemaps and the arcade physics since it's a simple and efficient solution.
  21. Maybe this is what you are looking for? http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=blank+tilemap.js&t=blank%20tilemap
  22. I can't get CSV to work either, I get the same length error as Will. This is in 1.1.4. The error occurs in: Phaser.Tileset#getIndex because the location array parameter is undefined.
  23. I used this example to see if I could get tilemaps to work. The only thing I needed to do to make it work was to change my TS definitions file. We use our own file and updates that when we find something missing or something wrong. Your bet bet would be to grab the newest one from the dev branch but in my experience even that file might still have some things that are not quite updated or have stuff missing so you will probably need to learn how to update the TS def file yourself, it's quite easy when you get the hang of it.
  24. We have a game using Flixel that we are now trying to port to Phaser. The game uses tilemaps made in Dame exported to simple csv files, like this: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,2,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,1,1,1,1,1,1,1,1,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0My question is now, are there any examples to show how to make tilemaps like this work in Phaser? In theory this might be possible but I have seen no examples of it working, only examples using Tiles and json.
  25. I just had this problem myself which drove me mad so I thought I'd share how to make tilemaps work in 1.1.4 with TS and in VS 2013 Express. In the preloader: this.load.tilemap( 'desert', 'assets/desert.json', null, Phaser.Tilemap.TILED_JSON );this.load.image( 'tiles', 'assets/tmw_desert_spacing.png' );Notice that you should use TILED_JSON and not JSON, you might have to modify your TS definitions file. In the game: var map: Phaser.Tilemap = this.add.tilemap( 'desert' );map.addTilesetImage( 'Desert', 'tiles' );var layer: Phaser.TilemapLayer = map.createLayer( 'Ground', this.game.world.width, this.game.world.height );layer.resizeWorld();You might need to modify the TS definitions of tilemap, addTilesetImage, createLayer and resizeWorld which should be something like: tilemap( key: string, tilesets?: any): Phaser.Tilemap;addTilesetImage( tileset: string, key: string ): void;createLayer( layer: any, width: number, height: number, group?: Phaser.Group ): Phaser.TilemapLayer;resizeWorld(): void;Lastly, the reason it probably won't work in VS is that the webserver doesn't want to load the json file, you get an 404 error. You can fix this by editing your your web.config file in the Solution Explorer to something like this: <configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> <system.webServer> <staticContent> <remove fileExtension=".json" /> <mimeMap fileExtension=".json" mimeType="application/json" /> </staticContent> </system.webServer></configuration>This worked for me anyway, now I just have to see if I can get it to work with csv files (I doubt that a bit).