
fillmoreb
Members-
Posts
71 -
Joined
-
Last visited
Everything posted by fillmoreb
-
Umz has got the right solution. Here's a fiddle I made a while back to answer a similar question. It should demonstrate how to accomplish what you want. Good luck. https://jsfiddle.net/mub2ps0c/7/
-
@bali33 Sorry for the late response, I've been very busy at work lately, so haven't had the time to check in here at the forums. I'm not sure why you're having issues. If you're still having trouble, go ahead and post your full source and I can help you track down the problem. @noesgames Sorry to you for the even later response. I haven't needed to get a notification on a completed animation, so the plugin doesn't have any system to do that. Sorry.
-
I would do something like this: var time_til_spawn = Math.random()*3000 + 2000; //Random time between 2 and 5 seconds. var last_spawn_time = game.time.time; update() { // This is your state's update loop var current_time = game.time.time; if(current_time - last_spawn_time > time_til_spawn){ time_til_spawn = Math.random()*3000 + 2000; last_spawn_time = current_time; spawnCustomer(); } }
-
Phaser.Rectangle is not a DisplayObject, it's not really meant to be drawn onto the screen. You can use the debugger to visualize where a rectangle is like this: game.debug.geom(ground,'#0fffff'); But I don't suggest doing this for all of your game's visuals. Instead I would make a sprite for the ground, add a graphics object as a child of that sprite, and draw a rectangle onto that graphics object, something like this: var g = game.add.graphics(); var groundSprite = game.add.sprite(); groundSprite.addChild(g); g.beginFill(0xFF0000); //Red Fill Color g.drawRect(0,0,game.world.width, 50); groundSprite.y = game.world.height - 50; You can then recolor the rectangle at will by doing this: g.clear(); g.beginFill(0x0000FF); g.drawRect(0,0,game.world.width,50); You could also experiment with using groundSprite.tint to recolor your shapes.
-
Dynamically Change Sprite Body/Polygon (Worms - like game)
fillmoreb replied to Fractal Games's topic in Phaser 2
Phaser's physics doesn't support bitmasks as the collidable body. If you choose to use them, you would most likely have to ignore Phaser's physics and create your own physics engine. If you're more comfortable working within the system that Phaser has set up, you probably want to stick with polygons. Once you've got it figured out they'll work just fine for you. Just choose whichever method feels like the best fit for you. I prefer bitmasks, but that's probably because I'm an old-school programmer. Here's a link to a worms clone that was written for HTML5. It's not phaser, but it's using polygons. You can go and check the method they are using for terrain deformation to help you get going. https://github.com/CiaranMcCann/Worms-Armageddon-HTML5-Clone/blob/master/src/environment/Terrain.ts -
Check to see if the mouse is over the sprite and if it is, you can manually force the hand cursor by doing something like this: this.game.canvas.style.cursor = "pointer"; sprite._setHandCursor = true; I'm not totally sure on the second line, but you might need to include it so that the sprite knows it's using pointer and needs to turn it off on mouse out.
-
The sprite's position never actually changes, which is why you don't get a change in the coordinates. If you want the apparent position of the planet use something like this: apparent_x = x + Math.cos(rotation)*orbit_radius*scale; apparent_y = y + Math.sin(rotation)*orbit_radius*scale; EDIT: Needing to multiply by scale depends on whether you want scale to affect the orbit radius or not. That's probably obvious, I just wanted to clarify.
- 2 replies
-
- pivot
- sprite rotation
-
(and 1 more)
Tagged with:
-
Well, you have a line in your code that says: game.debug.spriteInfo(sprite, 32, 32); However, you never define a variable called sprite. You probably meant to debug steve, right? Try replacing the sprite with steve: game.debug.spriteInfo(steve, 32, 32);
-
Dynamically Change Sprite Body/Polygon (Worms - like game)
fillmoreb replied to Fractal Games's topic in Phaser 2
To do this, I would probably walk around the edges of the visible pixels and create a point at the edge of each. This would create a very detailed polygon that perfectly matches the pixels. Then I would use Ramer–Douglas–Peucker algorithm to simplify the polygon. Honestly, though, I wouldn't do any of that. To do a Worms game, I probably wouldn't use polygons at all. I would probably represent the collidable parts of the level and sprites as simple bitmasks. You could then use bitwise operators to detect collisions and to cause terrain destruction. -
@Hadik, you may want to try Ninja Physics before you give up all together. It allows you to have circular physics bodies. That might be enough to make the balls bunch up the way you intend without bogging down the lower end machines.
-
I would try using cache.removeTextureAtlas("MyShip"); right before you try loading the new file. Might work.
-
I just looked through the code of Loader, and it looks like there are no provisions for doing what you want.
-
I don't have an good answer for you, but here's a thread where others were discussing fluid simulation: http://www.html5gamedevs.com/topic/6765-water-liquid-fluids/
-
As near as I can tell, this isn't really a bug. It's a limitation of arcade physics due to a couple of contributing factors. For one, arcade physics uses axis aligned bounding boxes for its physics simulations. Imagine it in real life: Take 500 wooden building blocks that aren't allowed to rotate, and try to form a circle out of them. It would be a lot more complicated than just pushing them all towards the center of your circle. Another other limitation is the way collide works. It checks a group of objects against a group of objects. It "un-overlaps" them if it finds them overlapped. But it won't necessarily see if the un-overlapping creates another overlap. This unfortunately allows objects to end up occupying the same space. This is a more apparent limitation when you have many many objects, like with the 500 balls in your example. After that happens, when the engine tries to "un-overlap" things in the next pass, it's going to tend to push them out along one axis rather than the other. This is what creates the cross shape you're seeing.
-
Well, it looks like you're trying to attach an event listener to a texture (you can't do that). But... it's hard to tell without looking at your code.
- 3 replies
-
- texture
- basetexture
-
(and 1 more)
Tagged with:
-
I would put all the images you want to move around into a Group, and change the position of the group. Add a little bit of logic into update to see which tiles are close to your viewport, and load them if they still need to be loaded. I probably wouldn't bother with Phaser's TileSet, it doesn't seem to lend itself well to lazy loading, and would probably be more kludging than it's worth to make it work right.
-
Boilerplate simply refers to the code that you have to write every single time you do a specific task. Here's an example of an HTML boilerplate. <!DOCTYPE html> <html> <head> <title></title> </head> <body> </body> </html> For the purposes of this conversation, however, you can use the term interchangeably with template. https://en.wikipedia.org/wiki/Boilerplate_code
-
Everything you've posted seems to be correct. I even made a quick jsFiddle to see if what you were doing works, and it does. https://jsfiddle.net/mub2ps0c/3/ Since your logic and function calls seem correct, my guess is that you are accidentally moving the character within the rotation function.
-
My guess is you have a scoping issue with this. You should be able to bind this to the function you're calling when you add the event listener. Something like: myButton.onClick.add(clickButton, this); If that doesn't work, you'll need to post more code so we can see better what the problem might be.
-
Here's an updated fiddle, showing that a combination of game.time.advancedTiming = true; and game.debug.text(game.time.fps, x, y, color) will successfully display the FPS. https://jsfiddle.net/bjrnw06c/2/