Loading images from a folder in resources ios

283 views Asked by At

I am attempting to load a sprite from a folder using the following statement

Sprite *sp = Sprite::create("Images/CloseNormal.png");

Now Images is a folder inside resources which has the file CloseNormal.png The above statement returns NULL Now If I move the image outside the folder into Resources and use the following code

Sprite* sp = Sprite::create("CloseNormal.png");

The above works

My directory structure in ios looks like this

|_Resources
   |_Images
        |_CloseNormal.png

Any suggestions why it cant load sprites from folders inside resources ?

1

There are 1 answers

0
yangguang1029 On

it's something about "group or folder" in xcode when add folder into project

also known as "blue or yellow folder"

enter image description here

when using "create groups", there is no need to use relative path.

oppositely, you must use actual relative path when using "create folder reference"

suggest you searching more about it, like google "xcode group or folder"