Skip to content

Integrating the SDK

AdsCraft turns selected gameplay parameters into fields you can change on the web without rebuilding. The SDK does three jobs: mark fields at build time, apply config at runtime, and expose the PA.* API to your game code.

Decorate a property once, in code:

import { _decorator, Component } from 'cc'
import { paField } from '@pa/sdk'
const { ccclass, property } = _decorator
@ccclass('Gameplay')
export class Gameplay extends Component {
@property
@paField({ label: 'Taps to win', min: 1, max: 100 })
taps = 30
@property
@paField({ label: 'Background music' })
bgm = true
}
  • label is what the web form shows.
  • min / max become the allowed range; options turns a string into a dropdown.
  • A field is exposed only if it is decorated. Undecorated properties stay private to the build.

Open the AdsCraft panel in Cocos Creator, pick an App and a Concept (or type a new Concept name), choose the startup scene and orientation, then click Build & upload. The extension:

  1. builds the project (web-mobile),
  2. extracts the schema from the decorated fields,
  3. compresses assets per your Assets tab options,
  4. merges everything into a single playable.html,
  5. checks the payload size against the channel limit,
  6. uploads the payload and creates a Build + a default Creative.

A build that fails — over the size limit, a Cocos build error — does not create anything on the dashboard.

The runtime applies the saved config before your game starts; read it through PA:

import { PA } from '@pa/sdk'
PA.onReady(() => {
const taps = PA.get('taps') // value applied for this Creative
PA.ctaClick() // fire the network CTA
})
API Use
PA.onReady(cb) run once config is applied and the game booted
PA.get(fieldId) read the applied value of a field
PA.ctaClick() trigger the current network’s call-to-action
PA.gameStart() / PA.gameEnd() report lifecycle where the network needs it

Field ids are stable per build; read them from the schema in the extension rather than hard-coding.