I got error in TMX in cocos2d - cocos2d-iphone

i have made Backgd.tmx using TmxTileMap.and i am trying to use it in my implementation as below
CCTMXTiledMap *tileMap = [CCTMXTiledMap tiledMapWithTMXFile:#"Backgd.tmx"];
[self addChild:tileMap];
but i got error as like
-[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found: Images/background.png
cocos2d: Couldn't find file:Images/background.png

Tiled saves the (relative) path to image files. But in Xcode, the directory structure is flattened hence there is no Images folder.
I suppose your tileset is in a Images subfolder of the folder containing the tmx file. You can either:
move the tileset images to the same folder as the tmx file (and update in Tiled accordingly or by editing the tmx file with a text editor)
add the Images subfolder to your Xcode project as a folder reference (blue icon) rather than as a group (yellow icon) - note: this will always add all files in that folder to the app bundle, this may not be desirable if you also keep other files (ie photoshop source files) in the Images folder or its subfolders
change cocos2d's TMX reader code to use only lastPathComponent of the tileset filename strings

Related

SFML Can't Load Image

I am trying to load an image with SFML, here is my code.
// Get the background texture
Texture bg;
if (!bg.loadFromFile("background.jpg"))
{
return EXIT_FAILURE;
}
Sprite background;
background.setTexture(bg);
background.setPosition(width / 2, height / 2);
and in the main loop:
window.draw(background);
Now I have included the background.jpg in every single folder for this solution, starting from C:/users/username/source/repos/thisSolution. However I am still getting the failed to load image error, is there some arbitrary folder where VS2017 would be looking for this file?
As #Arnav Broborah pointed, by default with Visual Studio, resources should be located into your project folder (where .vcxproj file is)
If you have created your project with "Create directory for solution", the
resulting hierarchy will be something like:
C:\Users\username\Documents\Visual Studio 2013\Projects\YourSolution\YourProject
Obviously, those names depends on the drive you installed VS, username, VS version, etc, but your resource files should go into the project folder by default.
You can change it in debug settings

JUCE image buttons without embedding files

Is there anyway to just include a file from a relative path using JUCE? Between graphics, up and down button states, I have about 40 images and trying to create them through the ProJucer causes thousands of lines (over 20,00 in this particular situation) to be generated and embedded in my GUI component. This is causing huge performance issues in Xcode for me. Is it possible to just include the files via relative path and save all that embedded code? The .cpp is so large even GitHub says they are too large to display. Any help is greatly appreciated.
To use embedded images in your project, but not have them taking up space inside each component's .cpp file as generated by the Projucer, do this instead:
Add the image files to the Projucer project itself.
When you save the Projucer project, the image data will be added to your project's BinaryData.h/cpp file that's located in the JuceLibraryCode directory.
When you want to create the ImageButton, instead of selecting 'create a new image resource' (which would put the binary data into your component's source directly), select the BinaryData resource that you created above:

How to add an image to a C++ project in Xcode

I would like to add an image to my C++ project in Xcode so that I can read that image and do something with it. How do I include the image into my project?
tried copy pasting both into my project and into the folder with my c++ source.
In Xcode 10, I can't put the image in the same folder as the executable, and I don't think it's a good idea anyway as this folder gets deleted when a clean is performed.
The solution I found when dealing with "Command Line Tool" projects in Xcode, is to modify or create a new Copy File Phase (and not a Copy Bundle Resources one) in Targets > Build Phases. But the default values should be modified:
Destination: Resources
Subpath: Nothing
Uncheck Copy only when installing
The image should then be added to this phase (using the + button). Beforehand, when adding the image to the project, selecting a target is not necessary, adding it to the Copy Files Phase will do it automatically.
The code will then look like this:
std::string filename("input.bmp");
bitmap_image image(filename);
Put the image in the same folder with the executable i.e. with the file in the Products folder.

Files being created in the wrong folder

To give a little context: I'm writing a program that uses text files and BMP files. For the text files I was provided with a class to manage them and I'm using EasyBMP for the BMP manipulation.
The problem I have is the files are being created in the wrong folder unless I provide the full path.
Example:
#include "EasyBMP.h"
int main(){
BMP picture;
picture.SetSize(640,480);
picture.WriteToFile("picture.BMP");
return 0;
}
Expected result: 640x480 BMP file created somewhere in my project folder (C:\Users[user]\Documents\C++\TP 1)
Actual result: 640x480 BMP file created in Eclipse folder (C:\Users[user]\Documents\Eclipse)
The same happens with any other file I write to disk.
It used to work fine on a different project so I'm guessing there's something silly I'm missing somewhere but I haven't been able to find a solution.
EDIT: The exact same code works fine on a different project.
If you don't specify a full pathname, files are stored in the process's current folder. You can change that in Eclipse (tell if which folder to run from when you run the process).
If you always want the files to be stored where your EXE is, or somewhere around the EXE, you can find the folder yourself(the first argument to main is the location of the EXE file).
The program will write the file in the working directory. That's because you used a relative path and relative paths are relative to the working directory.
Either specify a full path in your code, or ensure that the working directory is set to your desired value when running the program.

unable to display png and gives warning in some part of code in my application after msi installation

I want to know the complete method of msi installation because The msi file created when installed is not displaying the pictures that are of .png type why does this happen and how to solve this problem?
Before creating msi when I execute the program in the vc++2008 it is showing pictures. why I am not able to view png pictures, when I create the same program msi and other pics of bitmap type can be viewed.
I have placed png pictures in res folder, and followed the following procedure
solution explorer->ResourceFiles->right click mouse->add existing item->(added png files of res folder)
What else should I do to make my png pictures appear after installing msi.
I have used picture ctrl to display png.
The msi instaler (msiexec) does not work with png images. You can only use bmp and jpg images.
See the docs about the image properties:
http://msdn.microsoft.com/en-us/library/3kbk77sf.aspx
http://msdn.microsoft.com/en-us/library/8s4dddtk.aspx