Skip to content

thethepai/OpenHarmonyArkTSPushPopGame

Repository files navigation

ArkTS game

鸿蒙移动应用技术实验

special thanks to: @weilaibudengdai

brief view

alt text

alt text

alt text

alt text

alt text

usage

  • reverse and random new game
  • high score
  • quit confirm
  • welcome and about page

details

check exp constructions in ~picturebed\otherResources, ~assets

add reverse and new game button

use gameList's reverse function

Button('Reverse')
              .onClick(
                () => {
                  this.gameList.reverse()
                })

use Math.random() to generate new game list

Button('New Game')
              .onClick(
                () => {
                  ...
                  let test = Math.random()
                  ...
                })

persistent storage

define

PersistentStorage.PersistProp('highScore', 0);

call

@StorageLink('highScore') highScore: number = 0

quit confirm

define dialog window

@CustomDialog
struct CustomDialogExample {
  controller: CustomDialogController
  cancel: () => void
  confirm: () => void
  ...
}

complete call back function in @Entry @Component

dialogController: CustomDialogController = new CustomDialogController({
    builder: CustomDialogExample({
      cancel: this.onCancel,
      confirm: this.onAccept,
    }),
  })

  onCancel() {
    ...
  }

  onAccept() {
    ...
  }

pages switch and router

refer to HarmonyOS Developer pages:

构建第一个ArkTS应用

About

华中科技大学鸿蒙移动应用技术实验

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published