Steps
Steps
Project folders
Photsohop/bookShopX
- bookTOC
- library.psd
- {{bookName}}Icon
- downloadBtn
- saveBtn
- savingTxt
- purchaseBtn
- restoreBtn
- infoTxt
- Buy Product Action
- dialog.psd
- {{bookName}}Icon
- downloadBtn
- saveBtn
- savingTxt
- purchaseBtn
- infoTxt
- hideOverlayBtn
- {{bookName}}Icon
- library.psd
- bookFree
- page1.psd
- page2.psd
- bookOne
- page1.psd
- page2.psd
- bookTOC
Solar2D
main.lua
require("controller.index").bootstrap({name="book", sceneIndex = 1}) -- scenes.index {"library", "dialog"}
components/bookstore/model.lua
Host URL of yours if you set up your own server.
local YourHost = "http://localhost:8080" M.URL = YourHost.."/bookshelf/" M.backgroundImg = "bg.png"
books model
M.books = { bookFree = { name = "bookFree", versions = {"en", "jp"}, titles = {en="bookOne", jp=""}, descriptions = {en="desc", jp =""}, isFree = true, isOnlineImg = false, image = "App/bookFree/assets/images/title/bg.png", productNames = {apple = "bookFree", google = "bookFree", amazon = "bookFree"}, }, bookOne = { name = "bookOne", versions = {"en", "jp"}, titles = {en="bookOne", jp=""}, descriptions = {en="desc",jp=""}, isFree = false, isOnlineImg = true, image = "App/bookOne/assets/images/title/bg.png", productNames = {apple = "bookOne", google = "bookOne", amazon = "bookOne"}, } }
BookServer
compress_assets/main.lua
compress and copy each assets of books to BookServer/bookstore folder with assets.json
edit the book table and run it with Solar2D simulator
local books = { {project = "bookFree", serverFolder = "bookFree"}, {project = "bookOne", serverFolder = "bookOne"}, } local onLineImages = { {project = "bookFree", serverFolder = "bookFree", image = "assets/images/page1/bg@4x.png"}, {project = "bookOne", serverFolder = "bookOne", image = "assets/images/page1/bg@4x.png"}, }
bookstore folder
- bookFree/assets.json
- page1/assets.zip
- page2/assets.zip
- bookOne/assets.json
run http-server and it check json is available
http://localhost:8080/bookstore/bookFree/assets.json
- bookFree/assets.json
Solar2D simulator
menu > show sand box folder
you need to clean the following folders if you want to recover the initial state. * Application Support * Documents * TemporaryFiles
For device build, you must set the valid product IDs from apple, google or amazon. For IAP Debug Mode, set the same name value to each filed.
Debug mode
IAP Badger https://github.com/happymongoose/iap_badger
When you test it with debug as true for components/bookstore/model.lua , you need to set the book names as its dummies for the productNames.
Don’t use the official product names from apple, google or amazon. With official IDs, debug mode fails to return a book name and IAP not work correctly.
productNames = {apple = "bookFree", google = "bookFree", amazon = "bookFree"},
build.settings
iOS
if you use http server instead of https, please set your domain in build.settings
NSExceptionDomains
https://docs.coronalabs.com/guide/hardware/appleATS/index.html
Android
- config.lua needs google license key
- build.settings needs the permissions