androidcocos2d-androidcclayer

How to use getAssets in a class that extends CCLayer


I have a class that extends CCLayer. I have to get a text file from assets folder. But i couldn't use getAssets() in this class. How can i use getAssets() in a class that extends CCLayer???


Solution

  • Finally got the answer...

    Context context = CCDirector.sharedDirector().getActivity().getApplicationContext();
    InputStream is = context.getAssets().open("abc.txt");