I’m doing a lot of coding and many names I gave things in my .plist file are quite hard to remember, so in my .h file, I said
#define groundSquare01 "groundSquare_01_001-uhd.png"
So in my code, I added
#include "Definitions.h"
Next, I changed
auto g = Sprite::create("groundSquare_01_001-uhd.png");
to
auto g = Sprite::create(groundSquare01);
But Xcode gave me an error.
However, it didn’t mention what the error WAS.
So, what is wrong here?
I’m using V4.
Also, to answer your question:
what does and doesn’t go in a header file
and can you post the .h?
#ifndef Definitions_h
#define Definitions_h
#define groundSquare01 “groundSquare_01_001-uhd.png”
#endif
I’m just asking because I have images that have really hard names to remember that have to be used multiple times and the spritesheet is huge
This isn’t related to Cocos products specifically. I think you can answer this question with a google search. Preprocessor directives - C++ Tutorials
Just use the name of the #define
where it is needed.
auto mySprite = cocos2d::Sprite::create(groundSquare01);
the spec states that #defines should be in all caps though
Just a random thought, make sure these double quotes in the
#define groundSquare01 “groundSquare_01_001-uhd.png”
are ok.