GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

White Only Sprites in PhysicsEditor

KevinCrossKevinCross London, UKPosts: 1,893Member
edited March 2016 in Working with GS (Mac)

I created loads of white only sprites for a project I'm working on as I wanted to colour them programmatically, loaded them into PhysicsEditor to apply custom collisions but unfortunately can't see any of them against the white background of the app >.<

There aren't any options in PhysicsEditor to change the background colour from what I can see.

From what I can tell when you load a PhysicsEditor published file into GameSalad which has collision data for several images the custom collision data is matched up on the image name so am I right in thinking that I can't create copies of these images, change their colour to black, create the custom collision shapes in PhysicsEditor and then apply them to the white versions of the images? I hope that makes sense...

Some of them are hidden collider actors so I can change those to black and delete the white versions from GameSalad without any problem but what about the ones I want to remain white?

Some of these images have transparent centres, a little like the doughnut ring in the cookbook tutorial so I can't just use the shape tracer option as that only traces around the object, it doesn't pick up the hole in the middle and it's impossible to build the collision shapes like the example when the whole image is invisible in the program >.<

Comments

  • Braydon_SFXBraydon_SFX Posts: 9,109Member, Sous Chef, PRO, Bowlboy Sidekick GameSalad Employee

    I'm pretty sure I've applied a custom collision shape to an actor that did not have the image I originally created the shape based off of. So, I think you could create the shape off of a darker image and then apply the shape to the lighter image.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @Braydon_SFX said:
    I'm pretty sure I've applied a custom collision shape to an actor that did not have the image I originally created the shape based off of. So, I think you could create the shape off of a darker image and then apply the shape to the lighter image.

    Do you apply custom collision areas to multiple images in the one project in PhysicsEditor and then publish to one json file? Or do you create one json file for each image? For each image I can probably see how that would work but if it's all in one and you apply the whole json file to one actor it must match up on the image name. If that is the case then I suppose creating a black version of the sprite with the exact name would work.

    But thanks, I'll give it a try. Might be easier for me to try it on a new empty project

  • Braydon_SFXBraydon_SFX Posts: 9,109Member, Sous Chef, PRO, Bowlboy Sidekick GameSalad Employee

    I always create a new project for each image; it's just how I've done it. I haven't tried the other way but it sounds like it may save some time!

  • adent42adent42 Posts: 1,312Key Master, Head Chef, Executive Chef, Member, PRO GameSalad Employee

    If it's based on transparency, you can also start with the magic wand tool to get the basic shape blindly. It's not much help if you're fine tuning, but i find between the wand and changing the trace tolerance, I don't have to do much manual work. I tend to raise the tolerance to get fewer polygon points which means faster performance (generally).

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @adent42 said:
    If it's based on transparency, you can also start with the magic wand tool to get the basic shape blindly. It's not much help if you're fine tuning, but i find between the wand and changing the trace tolerance, I don't have to do much manual work. I tend to raise the tolerance to get fewer polygon points which means faster performance (generally).

    I didn't see the trace tolerance doing anything for me. I did try it. The trace around the ring works fine but the whole collision area is a solid circle, not a ring. I think I bumped the trace tolerance up to like 20 and didn't see anything. I'll have another go. I've got an invalid json file at the moment when trying to create a mini test project.

    Just noticed it's gone midnight here >.< so will give it a go tomorrow.

  • SocksSocks London, UK.Posts: 12,822Member
    edited March 2016

    @KevinCross said:
    I created loads of white only sprites for a project I'm working on as I wanted to colour them programmatically, loaded them into PhysicsEditor to apply custom collisions but unfortunately can't see any of them against the white background of the app >.<

    More generally speaking this is - for me at least - an ongoing issue with GameSalad, the system encourages users to author assets that you want to control the colour of in white, but makes no allowance for white as an image colour in the UI/interface, invisible actors in the image assets pane being the most obvious issue.

  • SocksSocks London, UK.Posts: 12,822Member

    @KevinCross said:
    From what I can tell when you load a PhysicsEditor published file into GameSalad which has collision data for several images the custom collision data is matched up on the image name . . . .

    There is no connection between an actor and its image and what collision data you import as far as I'm aware. I'm also a little confused by the idea that a "published file . . . has collision data for several images", I'm not sure that that means, mind you as soon as people start using 'published' and 'sprite' and any non-GS term I get easily confused :)

    I would make my image black (or any colour visible in PhysicsEditor), create your collision shape . . . . save this collision shape as a file . . . then import into GameSalad the white version of your image, apply it to an actor and then import the collision shape file.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @Socks said:

    @KevinCross said:
    From what I can tell when you load a PhysicsEditor published file into GameSalad which has collision data for several images the custom collision data is matched up on the image name . . . .

    There is no connection between an actor and its image and what collision data you import as far as I'm aware. I'm also a little confused by the idea that a "published file . . . has collision data for several images", I'm not sure that that means, mind you as soon as people start using 'published' and 'sprite' and any non-GS term I get easily confused :)

    I would make my image black (or any colour visible in PhysicsEditor), create your collision shape . . . . save this collision shape as a file . . . then import into GameSalad the white version of your image, apply it to an actor and then import the collision shape file.

    The reason why I think/thought there's a connection between the data and the file name is because you can have multiple images in the one PhysicsEditor file and publish all of those to one json file. When you apply that json file to an actor in GameSalad it doesn't then ask you which part of the json file you want to apply to the actor so it must match up on the image name (unless of course PhysicsEditor is only publishing one of the many images you've put into the PhysicsEditor project. I haven't looked at the data in the json file yet)

    @adent42 the transparency threshold definitely doesn't do much. It's still treating the transparent hole in the middle of the ring as a solid and therefore only applying a solid circle collision shape to the whole ring.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    So I've looked at the json file, one that has 12 images in and there's no mention of image names in it. There's no id's in the file at all so I'm confused as to how GameSalad knows which one to pick when you add it to an actor. Here's an example for two images in the one json file.

    {
    "rigidBodies": [
    {
    "normalized":false,
    "rescale":false,
    "origin":{"x":0,"y":0},
    "size":{"width":64,"height":64},
    "polygons": [
    [
    {"x": 10, "y": 19 },
    {"x": 34, "y": 8 },
    {"x": 54, "y": 20 },
    {"x": 30, "y": 56 },
    {"x": 10, "y": 44 }
    ],
    [
    {"x": 54, "y": 44 },
    {"x": 30, "y": 56 },
    {"x": 54, "y": 20 }
    ]
    ]
    },
    {
    "normalized":false,
    "rescale":false,
    "origin":{"x":0,"y":0},
    "size":{"width":640,"height":640},
    "polygons": [
    [
    {"x": 48, "y": 162 },
    {"x": 321, "y": 8 },
    {"x": 591, "y": 163 },
    {"x": 319, "y": 632 },
    {"x": 49, "y": 477 }
    ],
    [
    {"x": 591, "y": 477 },
    {"x": 319, "y": 632 },
    {"x": 591, "y": 163 }
    ]
    ]
    }
    ]
    }

  • SocksSocks London, UK.Posts: 12,822Member

    @KevinCross said:
    The reason why I think/thought there's a connection between the data and the file name is because you can have multiple images in the one PhysicsEditor file and publish all of those to one json file.

    From what I can tell that route doesn't suit your purposes, so stop it ! :) Just create an image you can see and use this to create a collision shape file.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @Socks said:

    @KevinCross said:
    The reason why I think/thought there's a connection between the data and the file name is because you can have multiple images in the one PhysicsEditor file and publish all of those to one json file.

    From what I can tell that route doesn't suit your purposes, so stop it ! :) Just create an image you can see and use this to create a collision shape file.

    I have two problems. One I've got multiple images in the one collision shape file (GameSalad obviously doesn't support that) that problem is easy to sort, just have one collision shape file for each image. Simple. The other problem is creating a ring collision (even with a black actor) I tried it and got an invalid json file. I did have polygons overlapping slightly though so that probably didn't help. Will have another go. The polygons don't connect nicely like they do in the cookbook example which was clearly done in the other program.

  • KevinCrossKevinCross London, UKPosts: 1,893Member
    edited March 2016

    I've sorted it now. I've created one collision shape with multiple points to fill the ring. Had to do it manually. The first time I tried it I copied the cook book example and created multiple polygons on it. That may have been the reason for the invalid json file.

    I also created the collision shape on the black image, published it and then applied that collision data to the white image in GameSalad. So you're all correct.

    Problems solved. Thank you

  • SocksSocks London, UK.Posts: 12,822Member

    @KevinCross said:
    I've got multiple images in the one collision shape file . .

    Stop doing that ! :p :) That's not what you need.

    @KevinCross said:
    The other problem is creating a ring collision (even with a black actor) I tried it and got an invalid json file.

    Why not simply make a 'C' shape ?

  • KevinCrossKevinCross London, UKPosts: 1,893Member
    edited March 2016

    That's what I did in the end. Created a closed C shape. There's probably too many points on it but I was just doing this for testing purposes. Now I know how to apply it to my own project shapes.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,906Member

    No gamesalad does not support multiple Collision shapes. You can only have one solid shape just as you showed above.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @Lost_Oasis_Games said:
    No gamesalad does not support multiple Collision shapes. You can only have one solid shape just as you showed above.

    Thanks. Got it now. But the cookbook page is misleading as it shows multiple polygons to build the doughnut collision shape. I realise that this is probably a screenshot from the other physics editor they support but I imagine I probably wasn't the first that followed the limited instructions and created loads of polygons in the same way in PhysicsEditor. Maybe someone in the GameSalad team could make it a little clearer, with maybe screenshots from both programs they support.

  • SocksSocks London, UK.Posts: 12,822Member

    @Lost_Oasis_Games said:
    No gamesalad does not support multiple Collision shapes. You can only have one solid shape just as you showed above.

    You can have more than one solid shape in a custom collision, for instance like the letter 'i' a line with a sepetate dot above it (so basically two unconnected polygons) . . . but I think you can only do it with PhysicsEditor as far as I understand.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,906Member

    @Socks said:

    @Lost_Oasis_Games said:
    No gamesalad does not support multiple Collision shapes. You can only have one solid shape just as you showed above.

    You can have more than one solid shape in a custom collision, for instance like the letter 'i' a line with a sepetate dot above it (so basically two unconnected polygons) . . . but I think you can only do it with PhysicsEditor as far as I understand.

    Hmmm will have to test that out. I was under the impression that it was only one. Now I have to try it!

  • adent42adent42 Posts: 1,312Key Master, Head Chef, Executive Chef, Member, PRO GameSalad Employee

    Because Box2d only supports convex shapes, in order to get convex ones, we assign multiple box2d fixtures to an actor (hence multiple shapes).

    So it is possible to do an "i", though the gap is rather small, so it'd have to be a giant I to make a difference in the game.

  • KevinCrossKevinCross London, UKPosts: 1,893Member

    @adent42 said:
    Because Box2d only supports convex shapes, in order to get convex ones, we assign multiple box2d fixtures to an actor (hence multiple shapes).

    So it is possible to do an "i", though the gap is rather small, so it'd have to be a giant I to make a difference in the game.

    So you're saying I could have created a doughnut/ring collider by adding multiple polygons to the one image? (like the example in the cookbook) I got an invalid json file when I did this in PhysicsEditor the first time but that could have been because there were polygons overlapping as its not the best program for doing complex/neat shapes in.

    Is it possible to update the cookbook page with screenshots from both programs for the two shapes you have on the page. The star and the ring

  • AlchimiaStudiosAlchimiaStudios Posts: 1,009Member, PRO
    edited March 2016

    @KevinCross said:

    @adent42 said:
    Because Box2d only supports convex shapes, in order to get convex ones, we assign multiple box2d fixtures to an actor (hence multiple shapes).

    So it is possible to do an "i", though the gap is rather small, so it'd have to be a giant I to make a difference in the game.

    So you're saying I could have created a doughnut/ring collider by adding multiple polygons to the one image? (like the example in the cookbook) I got an invalid json file when I did this in PhysicsEditor the first time but that could have been because there were polygons overlapping as its not the best program for doing complex/neat shapes in.

    Is it possible to update the cookbook page with screenshots from both programs for the two shapes you have on the page. The star and the ring

    I got this error (invalid json) a bunch with physics editor data, but for me it ended up just being the GS plugin producing incorrect JSON syntax. But you definently can have multiple polygons.

    I personally could never get the default plugin to work so I had to make a minor change to the GS PE plugin code to get it to add a "," in the right locations for it to be valid data for GS.

    Although some people got it to work with just the plugin as it is so... Dunno. Check out this thread

    http://forums.gamesalad.com/discussion/90325/custom-collision-weirdness-with-physicseditor/p2

    Follow us: Twitter - Website

  • SocksSocks London, UK.Posts: 12,822Member
    edited March 2016

    @adent42 said:
    Because Box2d only supports convex shapes, in order to get convex ones, we assign multiple box2d fixtures to an actor (hence multiple shapes).

    So it is possible to do an "i", though the gap is rather small, so it'd have to be a giant I to make a difference in the game.

    I only used an 'i' as an example of unconnected polygons, I'm not sure there's an actual demand from users for giant 'i' actors. :p

    But getting back to the point, I was easily able to have two normally shaped polygons making up a collision shape using PhysicsBody, it worked just fine.

    I made a swinging rope from small joined (jointed) sections, I made the collision shape for the short rope section actor like this:

    And then duplicated a bunch of these actors in a column like this (obviously here you can only see the collision shape rather than the actual actors) - the top actor was fixed (movable unchecked), so all the other sections could freely swing about beneath it.

Sign In or Register to comment.