[Cocos2D-X] initial view door diameter (11) CCUserDefault: save data

Source: Internet
Author: User

The CCUserDefault and SharedPreferences in Android are used to store simple data.

 

 

[Cpp]
// Obtain the bool Value
Bool getBoolForKey (const char * pKey, bool defaultValue = false );
// Obtain the integer value
Int getIntegerForKey (const char * pKey, int defaultValue = 0 );
// Obtain the floating point value
Float getFloatForKey (const char * pKey, float defaultValue = 0.0f );
// Obtain double-precision floating point values
Double getDoubleForKey (const char * pKey, double defaultValue = 0.0 );
// Obtain the string
Std: string getStringForKey (const char * pKey, const std: string & defaultValue = "");


// Set the Boolean Value
Void setBoolForKey (const char * pKey, bool value );
// Set the integer value
Void setIntegerForKey (const char * pKey, int value );
// Set the floating point value
Void setFloatForKey (const char * pKey, float value );
// Double-precision floating point value
Void setDoubleForKey (const char * pKey, double value );
// Set the string value
Void setStringForKey (const char * pKey, const std: string & value );

// Obtain the bool Value
Bool getBoolForKey (const char * pKey, bool defaultValue = false );
// Obtain the integer value
Int getIntegerForKey (const char * pKey, int defaultValue = 0 );
// Obtain the floating point value
Float getFloatForKey (const char * pKey, float defaultValue = 0.0f );
// Obtain double-precision floating point values
Double getDoubleForKey (const char * pKey, double defaultValue = 0.0 );
// Obtain the string
Std: string getStringForKey (const char * pKey, const std: string & defaultValue = "");
 
 
// Set the Boolean Value
Void setBoolForKey (const char * pKey, bool value );
// Set the integer value
Void setIntegerForKey (const char * pKey, int value );
// Set the floating point value
Void setFloatForKey (const char * pKey, float value );
// Double-precision floating point value
Void setDoubleForKey (const char * pKey, double value );
// Set the string value
Void setStringForKey (const char * pKey, const std: string & value );

 

Usage:


[Cpp]
CCUserDefault: sharedUserDefault ()-> setStringForKey ("UserName", "henn ");

CCUserDefault: sharedUserDefault ()-> setStringForKey ("UserName", "henn ");

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.