Giter VIP home page Giter VIP logo

Comments (10)

victorlevasseur avatar victorlevasseur commented on April 28, 2024

It's working when I load exactly the same texture (with relative path) inside the LoadResources of an object. I'm think it's related to the working directory...

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

Yes, it is related to the working directory: any time a resource (=file) used by a game is loaded, the working directory must be set to the game directory, then set back to the original working directory (=IDE directory). But normally, you shouldn't have to change the working dir.
You should be using gd::Resource and gd::ResourceManager. In an editor, you can do:

project.GetResourcesManager().GetResource(imageName)

to get a resource then use GetAbsoluteFile on the resource (make sure it is an image before). See a full example in SpriteObjectEditor.cpp (method GetwxBitmapFromImageResource)

When displaying an object, you should use in LoadResources a line like this:

project.GetImageManager()->GetSFMLTexture(imageName)

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

You're trying to factor the drawing code I guess, I didn't take a look at it for now but maybe this drawing code should not rely on the image manager but on a SFML sprite (or whatever it needs) passed as a parameter?

from gdevelop.

victorlevasseur avatar victorlevasseur commented on April 28, 2024

Yes, the TileSet class contains a wxBitmap and a SFMLTextureWrapper. The wxBitmap is only used in the editor but all the calculations are made on the SFML texture. So, even in the editor I need to load the texture.

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

@victorlevasseur Did you manage to find a solution? Maybe you have a suggestion about something that should be updated/refactored?

from gdevelop.

victorlevasseur avatar victorlevasseur commented on April 28, 2024

I've found a workaround : I get the current working dir, then I put the
game working dir, the image is loaded, then I put the old working dir.

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

Ok, we should think a bit about if there is a way to refactor something (either in the extension or in GD) because I'm not totally satisfied with this workaround (because it is a workaround as you said ^^)

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

@victorlevasseur any news about it? 😄 Did you think about a better solution or do you think the current solution is good enough?

from gdevelop.

victorlevasseur avatar victorlevasseur commented on April 28, 2024

I didn't find another solution and the workaround works fine. So, we can close that issue.

from gdevelop.

4ian avatar 4ian commented on April 28, 2024

Ok, sounds fine. :)

from gdevelop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.