Launch a Rating Dialog in the game


There are times when you might require the user of your app to provide a rating for your app. Now the question is if you bug the user immediately, they won't like it, if you do not ask, then you will never get a rating. Integrating a rating dialog is not very difficult, but how would you like it if you had a lua class that does all of that for you? All you need to do is call the class and it will check for all the rest and display the ratings dialog. Best of all, the parameters to control the behaviour are customisable. So you can set after how many uses should the Ratings Dialog show up? If the user declines to rate, do not bug them again. If you have a newer version then the settings should be rest and the user should be asked for ratings as appropriate.

The RatingsDialog depends on the PropertyBag engine, which is another class created by me that can be used for any generic purpose, it can be used to save scores, usernames, settings, whatever you want. It is a propertyBag that you can use. It functions similar to NSUserDefaults available in iOS.

The way to use the property class is simple
----Include the property.lua file in your project using
local prop = require("property")

--Declare a variable that uses the propertyBag
local propertyBag = prop:init()

--Set the properties in memory
propertyBag:setProperty ( "MyName", "Jayant C Varma" )
propertyBag:setProperty ( "MyCompany", "OZ Apps" )
propertyBag:setProperty ( "ThisClass", "PropertyBag" )
propertyBag:setProperty ( "Number", 1 )

print ( "The number is : " .. propertyBag:getProperty ( "Number" ) )

--Save to file
property:SaveToFile()

propertyBag:setProperty ( "Number", 100 )

print ( "The number is : " .. propertyBag:getProperty ( "Number" ) )

--Revert data from Disk
propertyBag:GetFromFile()

print ( "The number is : " .. propertyBag:getProperty ( "Number" ) )

Easy as that.

NOTE: Maybe I could get that to work with also providing a DefaultValue if the property is not available or defined as yet.

Comments

Popular Posts