Kokos

Members
  • Content Count

    11
  • Joined

  • Last visited

About Kokos

  • Rank
    Member

Contact Methods

  • Twitter
    Kasper_Mol

Recent Profile Visitors

742 profile views
  1. Hey, I'm building a top-down parking game, for this game we have levels in JSON which (among other things) determines where the player spawns and at what angle. The player consists of three sprites and three bodies (car and two front wheels) that are positioned relatively to each other. Everything goes well, until I try to spawn the car at an angle, because suddenly I no longer know the x and y coordinates of where to spawn the wheels, and it's a bunch of math to figure that out especially as phaser groups fix this problem. Enter example of my problem #1: https://jsfiddle.net/tv4j4tw1/ What I did here is simply create two sprites in a group, positioned them, positioned the group, and then added a body to the sprites. However the bodies spawn completely out of place. If this actually worked properly I'd have no issues. You can ask why do you even need a group here? I do because of the angles mentioned above, if this group would get an angle it'd be a lot harder to figure out the coordinates of the squares. Now we go into where I tried to hack my way out of this problem: https://jsfiddle.net/tv4j4tw1/1/ Ha! This works, I use the group to position the sprites, and then take the sprites out of the group and position them according to their world position while in the group. It's hacky, but I can live with it. Sadly it stops working once I add the angle (which is the whole reason I'm doing this weird stuff): https://jsfiddle.net/tv4j4tw1/2/ The world position is wrong, and the squares still end up in the wrong place. So, I hope I'm doing something fundamentally wrong and getting the hack to work is a silly idea. Halp.
  2. Kokos

    Phaser rope issues

    Ah, that sucks. I guess I'll go the hacky route and see if I can get it to perform. Thanks for the insight.
  3. I'm trying to use Phaser Ropes in order to populate the top of a curved world with ground. As the rope is a mesh that distorts an image its perfect for this purpose. However I'm running into two issues. 1. According to the docs, a Phaser Rope is "a Sprite that has a repeating texture.". This doesn't seem to be the case however, with a simple fiddle it already shows that the texture is stretched (and loses its aspect ratio in the process): https://jsfiddle.net/qruppmzu/ Is it possible to actually turn this into a repeating texture instead of causing it to stretch? Currently I need to use a whole lot of ropes to populate the world, which becomes heavy on performance really quickly. I can generate / move the ropes as you progress through the world but having one rope seems like a better idea (if it works). 2. Even though the constructor allows it, the rope doesn't work with texture atlasses. How would I go about getting this to work? My framework depends on everything being in an atlas, apart from rebuilding it makes little sense to have one single sprite outside of the atlas because of a bug like this. See: https://jsfiddle.net/qruppmzu/1/
  4. It seems to be working! Not for everything, and I have some other scaling issues that come up because of it. But at least some of it is now anti aliased (after forcing their dimensions to be powers of two). Doesn't work for canvas though EDIT: Also getting this to actually work with normal dimensions turns out to be really hard. Powers of two don't really align with the sizes I have to give the sprites.
  5. I'm having a problem with scaled down sprites, they don't seem to be smoothed properly. In the screenshot below you can see the sprite on the left, its actual size is about 4 times as big. The original sprite is used on the model (this is a dress-up game), and the scaled-down sprite is used for the thumbnail. I re-use sprites as much as possible to prevent inflated file-sizes. It's not a resolution issue, as you can see from the sprites to the right, they are smoothed very nicely. The further I scale a sprite down, the worse it gets. The sprites are built on BitmapData, I've also tried running a resize on the sprite.key (BitmapData) instead of changing the sprite.scale, but that just removes the sprite all together (and to be honest I'd rather not do any more bitmapdata manipulations, as I have a lot of those in this game). Is there a reason why this is happening, and does somebody have a good idea on how to fix this? My PIXI scaleMode is set to the default Linear, and all Phaser settings for smoothing are on their default on states (I've tried explicitly turning everything on, which had no impact).
  6. Yeah, a different solution would be not using the sprite input handlers, but write my own event handlers that work on the container but move the other sprite. However then i'd have to rewrite a bunch of code that's already implemented in sprite inputs. I was already doing position logic in my update because in the actual game I'm dragging multiple sprites, not one. Which means that I have one draggable sprite that updates the other sprites positions according to his own. Right now I want to move into testing quickly, so I just wanted something that would work and be fast to implement. I might end up writing a proper solution at some point.
  7. Awesome! I have to reposition the hitArea every time the sprite is dragged, but this is a pretty good fix. Thanks!
  8. Hey, I'm trying to build a container with scrolling content. How I've done this is I've created a container, this container has a mask of the same size and then the content is a sprite with drag inputs enabled. The content sprite doesn't show outside of the container because of the mask, but I can still drag it by clicking outside of the container. Here is an image to illustrate what I'm trying to achieve: (container in gray, dragsprite in red, masked parts of dragsprite in faded red) So my problem is I can still click the faded red parts to drag the sprite, even though I can't see them. I've made a quick fix now by having another sprite outside of the container with input enabled and a higher priorityID, but this is a very hacky solution as the outside sprite doesn't need inputs. Is this a limitation of the sprite inputhandlers, or am I missing something? The only real solution I see now is writing my own drag script and handlers (which is fine, but more work).
  9. Makes sense I guess, there is no getSprite either for cache since it works on the source assets. I just realised I can just do new Phaser.Image(), which does the trick and makes the most sense. Thanks.
  10. I just started implementing textureatlases into my project, which is working perfectly for the most part. However, in some places in my project I use game.cache.getImage, which doesn't work anymore. An old game.add.sprite(x,y,key) has simply turned into game.add.sprite(x,y,atlas,key), but there is no game.cache.getImage(atlas,key). I need to get the image from cache because I use it as a mask, and it doesn't need to be added to the game. I fixed my problem now by simply using game.add.image, and then destroying the image after using it, but that is not an optimal solution. Is there a way to get this to work?