BobDylan

Members
  • Content Count

    20
  • Joined

  • Last visited

  1. Ok thanks again, I was hoping there was an easy solution. I think I can manage to do it with the method I mentioned,but it's very hard to get it right. It would help if there was something like a 'bounced' or 'blocked' property (or event), to check which sprite is blocking the other sprite. At this moment I'm using a collision-handler to find the block that the playersprite bumped into, but it's a bit tricky because the block that the player stands on is sometimes also colliding (especially when it's moving up and down). And sometimes there's no collision at all, because the velocity was already down to 0.
  2. I have a game with a player sprite that moves on top of platforms (like Mario). Right now it works with Arcade physics for the y-axis and tweens for the x values, so I can control the horizontal movements very precisely. All moves of the playersprite end on a 64x64 grid. So when a tween ends, the x value is always a multiple of 64. Now I want to implment the physics engine for the x-axis as well, but I'm having trouble to achieve the same grid-value thing as above. When the playersprite bounces into walls, i want it to move to the nearest 64x64 position (but looking natural, of course). I already tried using calculating the nearest 64x64 coordinate, maintaining the direction of the current movement and keeping the velocity at speed until the exact point is reached, but this ended up very messy, because sometimes the sprite moves over this point because of a high speed, and I have to set the sprite back, which looks really weird. Hope the above is clear. Basically I want movements to fixed coordinates, but WITH a physics engine. Any ideas how to achieve this?
  3. I'm trying out the P2 physics engine, but I'm thinking I only need physics enabled for the y-axis. For example, a car-sprite that moves from left to right on a bumpy road. I would like the car to bounce up and down, when there's a bump in the road, but it needs to maintain a constant horizontal movement, and no weird collisions that make the car move left or or extra to the right. Is this possible with P2, or should I use Arcade physics (or maybe no physics engine after all) ?
  4. I'm experimenting with P2 physics. I have a game where there are several platforms directly next to each other, with no pixels between them. When I enable P2 physics on these platforms they start bouncing like crazy, as if they're pushing each other out of the way. Already tried applying materials and changing the friction, restitution, kinematic properties but I couldn't solve this. Any way to avoid this from happening?
  5. I'm trying to understand how Phaser tilemaps work (with a map size much larger than the screen). When the camera moves, are the tiles that were off-screen painted instantly or were they already painted on a big bitmap (as large as the whole map), which is simply moved when the camera moves? If it's the second option, wouldn't this become very slow with a map of 10000x10000 tiles ?
  6. Hi, just wanted to know if there's already built-in support for creating a sprite that is made up from different tiles. I know TileSprite is used to give a sprite a texture, but that's not what I mean. I also don't mean a sprite from a spritesheet, for animations. I mean a sprite of let's say 128x128 pixels that is made from 4x4 tiles of 32x32 pixels. I'm now struggling to do this myself, by using a bitmapData object and copying tiles, but was just wondering if maybe I'm re-inventing the wheel here.
  7. I'm trying to extend Phaser.Sprite to my own sprite class, to add some extra features. I don't like the prototype way of extending objects, so I implemented my own extend-method (similar to John Resig's Simple Javascript inheritance). I want to create a sprite, using an object that defines its properties (such as color, width, height, texture, etc.) To do this, I want to create a bitmapData object inside a method of my new class. The problem is that methods only exist after creating a object. But the create function of Phaser.Sprite already expects the bitmapData to be ready! I found a workaround by first creating the object with only the game parameter: var playersprite = Phaser.Sprite.create(game);and then calling a newly defined method initProperties(props) : var bmd = this.game.add.bitmapData(props.width, props.height);bmd.ctx.beginPath();bmd.ctx.rect(0,0,props.width,props.height);bmd.ctx.fillStyle = props.color;bmd.ctx.fill();this.loadTexture(bmd);Have no idea if this makes sense, but it works.
  8. I'd like to be able to do the following : var playersprite = Phaser.Sprite.create(game);playersprite.x = 100;playersprite.y = 100;playersprite.key = 'dude';instead of var playersprite = Phaser.Sprite.create(game, 100, 100, 'dude');So is there a way to just create the sprite first, and then afterwards assign its properties ? (The reason for wanting this is a bit complex, but has to do with extending Phaser.Sprite to a different class)
  9. Tried again on Chrome (after restarting my computer) and it works now. Don't know what was wrong... 20-40% CPU seems quite a lot, so maybe playing mods in the background of actual gameplay would not be such a good idea... Quite amazing that an Amiga 500 played these mods 25 years ago without any problems on a single-core cpu that's 1000x slower than my computer now... Thanks for the sources, I'd already hacked your examples to try it out in my game
  10. Very impressive, jwothke! Can't get them working on Chrome (37) though, but in Firefox it works great. Is there a difference between the versions in terms of CPU-usage ? And would the amount of samples and number of simlutaneously played samples in the mod make a big difference in CPU usage?
  11. When I create a repeating tween that yoyos with : var tween = game.add.tween(sprite).to({y: sprite.y+100}, 1000, Phaser.Easing.Linear.None, true, 0, 9999, true);it restarts beautifully when I leave the browser and return. But when I create a chained tween that loops, like : var tween = game.add.tween(sprite).to({y: sprite.y+100}, 1000, Phaser.Easing.Linear.None, true, 0, 0, false);tween.to({y: sprite.y}, move.time, Phaser.Easing.Linear.None, true, 0, 0, false);tween.loop();then the tween is stopped and doesn't always restart when I return to the browser (but sometimes it does, after a while!). Is there a reason for this, or is this a bug? Any way to make this work? UPDATE It seems the autostart of the second chained tween causes this behaviour. When I only set autostart on the first tween, the tween is being restarted when I return to the browser.
  12. Thank you lewster32 , the following does work : blocksprite.body.moves = false;The player now stays on top of the blocks, whatever movement is done to the block underneath. However I get the feeling from you guys that I'm doing something that gets me in trouble some day. The reason I want to use tweens for the block movements, is because I need easing, which I find very hard to do with changing the velocity of the blocks only. Any way to get a nice easing (bounce) effect on those blocks without using a tween?
  13. I have a game where a player-sprite can jump on top of blocks. These blocks are moving vertically up and down (with a tween). Arcade physics and gravity is enabled on the player-sprite only. But sometimes the player-sprite falls 'through' a block, as if the physics engine of the player can not calculate correctly if there's a block underneath the player. Can anybody tell me why this is happening, and how to prevent this ?
  14. In my web-applications I use jQuery a lot, for example $.each() to iterate over arrays, etc. I would like to use these in a Phaser game as well. I could also use jQuery Mobile which is a bit lighter. Is this a good idea, or is this very likely to slow my game down? (Of course I understand I cannot use the DOM-selectors that jQuery is famous for).
  15. Somehow the event is fired multiple times, when I have multiple load's in the preload. I'm using different gamestates now, which is the supposed way to load assets in multiple stages.