Bookstore

Bookstore

TODO

  • library.psd, dialog.psd, textLabels.psd page_custscene.psd

  • restore.psd showOverlay will be used

  • library filter

    • All/Downloaded/NotPurchased
  • build.settings

    • omit editor.template/assets
  • library page portrait

  • restore

    • download all
    • status recovered (downloaded) book
  • scroll view for library/table page

  • UXP

    • cp components/bookstore/booktoreX.lua to bookTOC/scenes/library

    • add filter in library page

      Can create a storybook like? navigation bar?

  • Test versions

Bookstore app contains the multiple kwik projects(books) inside. The lua files of each book are embedded in the app binary but the assets such as images, audio files of each book are not embedded in the app binary. They are downloadable from a web server. Due to Apple’s regulation, Solar2D does not allow to load the lua files (programming code) via Internet. The lua files must be embedded in the app binary but the other assets can be transfered from http server to the app.

A library page controls which book to be loaded with In App Purchase. User clicks a book icon on thubnail view on a library page, and a purchase dialog appears if user wants to buy one. A project called bookTOC(Table Of Content) contains library.psd and dialog.psd

When you like to add new books, you need to update the model.lua of bookTOC to include a new book information.

You can create as many as books but Bookstore is not designed to hold hundreds of books.


Sample file

Please download the sample project from here.

  Photoshop
   β”œβ”€β”€ bookFree
   β”‚   β”œβ”€β”€ page1.psd
   β”‚   └── page2.psd
   β”œβ”€β”€ bookOne
   β”‚   β”œβ”€β”€ page1.psd
   β”‚   └── page2.psd
   └── bookTOC
       β”œβ”€β”€ dialog.psd
       └── library.psd

  Solar2D
    β”œβ”€β”€ App
    β”‚   β”œβ”€β”€ bookFree
    β”‚   β”œβ”€β”€ bookOne
    β”‚   └── bookTOC
    β”‚
    β”œβ”€β”€ components
    |    β”œβ”€β”€ bookstore
    |        └── model.lua
    └── main.lua

  BookServer
    β”œβ”€β”€ compress_assets
    |       └── main.lua
    └── bookstore
        β”œβ”€β”€ bookFree
        └── bookOne

BooKServer

  • copy_books script archives each assets.zip of books into BookServer/bookstore folder.

  • Using node.js, install http-server and run

    cd BookServer
    http-server

    Set the url of http://localhost:8080/bookstore to Solar2D/components/bookstore/model.lua

    local M = require("components.bookstore.model.base")
    --
    M.debug = true
    M.URL = "http://localhost:8080/bookstore/"
    ...
    ...

Solar2D

  • Open main.lua with the simulator

Solar2D

Solar2D project has main.lua in the root directory.

    β”œβ”€App
    β”‚  β”œβ”€book01
    β”‚  β”œβ”€book02
    β”‚  └─bookTOC
    β”œβ”€extlib
    β”œβ”€lib

    build.settings
    config.lua
    main.lua
  • main.lua

    There is just one line to load “bookTOC” book

    require("controller.index").bootstrap({name="bookTOC", sceneIndex = 1}) -- scenes.index

    App/bookTOC/scenes/index.lua has a table of page names, so sceneIdex = 1 means to open library page.

    local scenes = {
     "library",
     "dialog"
    }
    return scenes
  • build.settings

    You may need to add permissions for your app. The following permissions are default

        android  = {
          usesPermissions  = {
              "android.permission.INTERNET",
              "android.permission.WRITE_EXTERNAL_STORAGE",
              "com.android.vending.BILLING",
              },
        },
  • config.lua

    please add google license key for android device.

      license =
            {
                google =
                {
                    key = "Please set your google license key",
                },
            },

bookTOC

library.psd shows the thumbnail of books and the buttons for purchase and download

  • Each {{bookName}}Icon

    it is a placeholder and the following layers are copied to the position of each {{bookName}}Icon

    • downloadBtn
    • savedBtn
    • savingTxt
    • purchaseBtn
  • restoreBtn

    it restores a book purchased history from one of online store(Apple, Google, Amazon)

dilaog.psd shows a book image and the IAP buttons and information text

  • downloadBtn
  • savedBtn
  • savingTxt
  • purchaseBtn
  • infoTxt
  • hideOverlayBtn

bookFree

  • page1.psd

  • page2.psd

    shows the following goto buttons

  • Goto TOC

  • GOto page1

  • Goto Next Book


bookOne

page1.psd

  • page2.psd
  • Goto TOC
  • GOto Title
  • Goto Previous Book

BookServer

Please use the script to zip the image, audio files as zip files

  • compress_assets/main.lua for Corona Simulator

    command.setServerFolder("macos", "bookstore")
    --command.setServerFolder("win32", "bookstore")
    
    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"},
    }
    ...
    ...