Not able to load Images from pList - cocos2d-x

I am porting my game on Windows 8 phone. Its already live on iOS and Android.
Its crash when I try to load images from a plist.
Unhandled exception at 0x69B76451 (libcocos2d.dll) in WickedChicks.exe: 0xC0000005: Access violation reading location 0x00000018.
My code is simple:
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile ("CommonObjects.plist");
My CommonObjects.plist and its png are present in resource folder & is working fine on iOS and Android.
Its giving null for
CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
in
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
method.
Thanks in Advance

Right click on the .Plist file
Go to Properties.
In the Build Action , set it to "Content"
and in "Copy to output Directory" section , set it as "Copy Always"
Hope this work for you.

Related

How to set Image Source to a picture from .dll or .winmd in windows phone 8.1?

I am new to windows phone 8.1 developping and focus on library dev.
In the wp 8.0 era,I know if I want to create a Image instance.
I just write
amapLogo.Source = new BitmapImage(new Uri("/Com.AMap.Api.Maps" + ";component/Resources/ap2.data", UriKind.Relative));
need to point here is that "/Com.AMap.Api.Maps" is my library output dll
It works fine.
If I keep the same code in wp8.1 developping
exception appears
An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details.
I browse http://go.microsoft.com/fwlink/?LinkID=215849
and find that two ways to set the ImageSource correctly.
the ms-appx or ms-appx-web scheme to create an absolute URI.
but it is used for getting a resource in the app package
what I want is getting a resource from my dll
so
What can I do to create a Image instance using way of setting
ImageSource.
Or is there anther way to do what i want?
Thanks!
Just Solve it!
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965322.aspx
To access files stored inside the same package, but from a class library, use the class library name:
<Image Source="/ClassLibraryName/images/logo.png" />

writeablebitmap in windows phone 8.1

I create universal project type in vs 2013 for 8.1.
In windows phone project i added reference to WriteableBitmapEx via nuget. In references i see WriteableBitmapEx.WinRT. I write code which creates WriteableBitmap from content (use image in project with Content and Dont copy properties). Next i create Image and set source to WriteableBitmap and add image in LayoutRoot grid. In emulator i see this image, thats ok!
Next i call DrawLine method from WriteableBitmap and call WriteableBitmap.Invalidate().
I dont see my line...why?
1) Why reference name ends with .WinRT, is this normal?
2) Why invalidate method not work?
NOTE: in windows phone 8 project (not universal) all works properly! And reference name not ends with .WinRT.
Help me please!
As already said in my comment, I had the same problem. After hours of confused searching, I finally found this trivial reason:
For universal apps, there are actually two projects: MyProject.Windows and MyProject.WindowsPhone. You need to add the nuget package for both of them (they have separate references) and everything will work.

System.Windows.Application.get_MainWinndow() exception Windows Phone

I have created a small app for Windows Phone 8. When I run it I get the following error:
((System.Windows.Application)(this)).MainWinndow threw an exception of type System.NotSupportedException at System.Windows.Application.get_MainWinndow()
I have searched for a solution to this but not much information out there.
My main page is called WelcomePage.xaml which is the first page that gets loaded and when exception is thrown during test on emmulator, but I'm not sure if that is the problem or even how to check if it is. My thinking being that I changed the name of MainPage.xaml to WelcomePage.xaml and this has maybe upset something.
Any ideas how I would go about solving the above problem, apologies I'm new to VS and Windows Phone C#?
J
Have you checked WMAppManifest.xml file in Properties path?
In the Application UI Tab, the Navigation Page should be changed to WelcomePage.xaml but not MainPage.xaml.

Cocos2d-x: Is there a way to get a content of CCUserDefault's file?

I need to get a content from a file in which CCUserDefault() stores its data. Is there a way to get it? I guess my storage is corrupted so I need to check its content.
I've tried following:
if ( cocos2d::CCUserDefault::sharedUserDefault()->isXMLFileExist() ) {
cocos2d::CCLog( "XML exists!" );
} else {
cocos2d::CCLog( "XML not exists!" );
}
So I get "XML not exists" on Android and iOS but a user setting successfully loads. Where CCUserDefault() stores its data now?
Because cocos2d-x does not create xml file to store data in android and ios. A little digging into the "CCUserDefault.cpp" showed me this at the start of the file
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
which means that cocos2d-x does not use the conventional xml creating and storing data in these two platforms.
I don't know about IOS, but in android, they may be using shared preferences now. As mentioned in this link as well. To read share preference file, u have to write some code in JNI. Follow these posts for reference:
Android: Viewing SharedPreferences file?
Where are shared preferences stored?
In Mac the xml file of ccuserdefault is created in
/Users/yourusername/Library/Application Support/iPhone Simulator/(select your
version)7.0.3/Applications/(something like this)9C9FF1EB-0674-4FA9-A113
D9E3DAD7B2CB/Library/Preferences/com.yourcompany.projectname.plist
here open this plist and you can see the key and the value which is stored on the key
Make sure to keep your library folder unhidden by running the command in terminal
chflags nohidden ~/Library

ZIP Embedding throws error

I want to embed a ZIP-file into my AS3/Air-application (with Flash Builder) and open it via FZip. For embedding, I use this code:
[Embed(source='../bin/art/resources.zip', mimeType="application/octet-stream")]
public static const rsClass:Class;
When I try to save the project the program chrashes and throws an error:
"Workspace is being build" has encountered a problem. During "Workspace is being build" an internal error has occured. (this is just a bad translation, not original) Java heap space
I click OK, the internal error appears:
The error "Disc space too low" has appeared. Look into the Readme-File at "Run Eclipse" you will find information [...] It is recommended to end the workbench. Do you want to end the workbench? yes/no
In an earlier version of this post I said, that the program doesnt start. That is not true. Only saving causes this error. Because of the saving errors, an earlier version of the program is started, but without errors. When I try to make a bytearray out of the zip, it causes an error (initial content not found), but I suppose the zip doesnt load, so this is not unusual.
you should NOT embed this ZIP but load it instead, you can add to the AIR package any files/folders.
To do it:
in Flash IDE go to "AIR for Android Settings" or "AIR for iOS Settings" and at the bottom of the dialogue box you have "Included files:" field then add folder or file you need,
for FlashDevelop what ever will be in bin folder will be packaged in air as described here
In Flex it will be the src folder and in the export wizzard you can select which files to include like described here.
Edit also you should consider for very large files following idea:
don't include big files (or just basic elements) and download big files and save on user device e.g. on sdcard, and then load it from there.
best regards