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.
1. Mark parameters with @paField
Section titled “1. Mark parameters with @paField”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}labelis what the web form shows.min/maxbecome the allowed range;optionsturns a string into a dropdown.- A field is exposed only if it is decorated. Undecorated properties stay private to the build.
2. Build and upload
Section titled “2. Build and upload”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:
- builds the project (
web-mobile), - extracts the schema from the decorated fields,
- compresses assets per your Assets tab options,
- merges everything into a single
playable.html, - checks the payload size against the channel limit,
- 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.
3. Read the config with PA.*
Section titled “3. Read the config with PA.*”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.