您的plist的耗材密鑰應該看起來像這樣。
<key>Consumables</key>
<dict>
<key>com.yourcompany.yourapp.handfulofcoins</key>
<dict>
<key>Count</key>
<integer>10</integer>
<key>Name</key>
<string>CoinsInMyApp</string>
</dict>
<key>com.yourcompany.yourapp.bagofcoins</key>
<dict>
<key>Count</key>
<integer>100</integer>
<key>Name</key>
<string>CoinsInMyApp</string>
</dict>
</dict>
我匹配字符串「CoinsInMyApp」來計算購買的硬幣數量無論哪個耗材它們從何而來。在上面的例子中,如果用戶購買1個bagofcoins和2個少數幣,MKStoreManager存儲120個關鍵字CoinsInMyApp。
方法,
- (BOOL) canConsumeProduct:(NSString*) productIdentifier
- (BOOL) canConsumeProduct:(NSString*) productIdentifier quantity:(int) quantity
會告訴你,如果你有足夠的產品。
當玩家使用硬幣,你應該讓MKStoreKit知道通過調用
- (BOOL) consumeProduct:(NSString*) productIdentifier quantity:(int) quantity
你可以通過調用
[[MKStoreManager numberForKey:@"CoinsInMyApp"] intValue];
PS獲得的硬幣數量:您可以使用MKStoreKit最新版本通過使用-fobjc-arc標誌編譯它的非ARC項目。
我在這裏寫了這裏http://blog.mugunthkumar.com/articles/migrating-your-code-to-objective-c-arc/
非常感謝!還有一個問題,如果你允許的話:當我們第一次發佈遊戲時,我會給用戶3個硬幣:\t if([MKStoreManager objectForKey:GoldenCoinsID] == nil)[MKStoreManager setObject:[NSNumber numberWithInt:3] forKey :GoldenCoinsID];' – 2012-07-16 03:32:55
我是對還是錯? – 2012-07-16 03:34:01
這應該可以正常工作。 – Mugunth 2012-07-17 09:46:33