pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Guides

  • Table of Contents
  • App Resources
    • Animated Image - アニメーション画像
    • App Assets - アセット
    • Converting SVG to PDC
    • Fonts - フォント
    • Images - 画像
    • Pebble Draw Command File Format - PDCファイルについて
    • Platform-specific Resources - 特定のプラットフォーム向けリソースの設定
    • Raw Data Files - 生データ追加とその利用
    • System Fonts - システムフォント一覧
  • Appstore Publishing
  • Best Practices
  • Communication
  • Debugging
  • Design and Interaction
  • Events and Services
  • Graphics and Animations
  • Migrating Older Apps
  • Pebble Packages
  • Pebble Timeline
  • Rocky.js
  • Smartstraps
  • Tools and Resources
  • User Interfaces

Platform-specific Resources - 特定のプラットフォーム向けリソースの設定

Aplite、Basalt、Chalk のいずれか 1 つ以上のプラットフォームで、異なるバージョンのリソースを使用したい場合があります。これを可能にするため、リソース ファイルに、特定のプラットフォームに関連する属性で「タグ付け」できるようになりました。

各プラットフォームには次のタグが存在します:

Aplite Basalt Chalk Diorite Emery Flint
rect rect round rect rect rect
bw color color bw color bw
aplite basalt chalk diroite emery flint
144w 144w 180w 144w 200w 144w
168h 168h 180h 168h 228h 168h
compass compass compass compass compass
mic mic mic mic mic
strap strap strap strap strap
strappower strappower
health health health health health

リソースにタグを付けるには、ファイル名の後にチルダ(~)を使用してタグを追加します。たとえば、example-image~color.png とすると、カラー プラットフォームでのみリソースが使用され、example-image~color~round.png とすると、ラウンドでカラーのディスプレイを持つプラットフォームでのみリソースが使用されます。ファイルが使用されるには、すべてのタグが一致する必要があります。プラットフォームに一致するファイルがない場合、コンパイル エラーが発生します。

プラットフォームに適したファイルが曖昧な場合、コンパイル時にエラーが発生します。たとえば、example~color.png と example~round.png の両方を持つことはできません。Chalk 用にビルドする際に、どちらの画像を使用するかが不明確だからです。代わりに、example~color~rect.png と example~round.png を使用してください。複数の画像が一致する可能性がある場合は、タグが最も多いものが優先されます。

プラットフォーム固有のタグ(aplite、basalt など)は避けることをお勧めします。将来新しいプラットフォームをリリースする際に、そのプラットフォーム用の新しいファイルを作成する必要があります。ただし、説明的なタグを使用すると、適切に自動的に使用されます。また、プラットフォームタグは特別ではないことも注目に値します:example~basalt.png と example~rect.png がある場合、これは曖昧(両方とも Basalt に一致)であり、コンパイル エラーが発生します。

ファイル構造の例を以下に示します。

my-project/
  resources/
    images/
      example-image~bw.png
      example-image~color~rect.png
      example-image~color~round.png
  src/
    main.c
  package.json
  wscript

このリソースは、以下のように package.json に表示されます。

"resources": {
  "media": [
    {
      "type": "bitmap",
      "name": "EXAMPLE_IMAGE",
      "file": "images/example-image.png"
    }
  ]
}

単一プラットフォームのリソース

特定のプラットフォームにのみリソースを含めたい場合は、package.json の media 配列内のリソースのエントリに targetPlatforms フィールドを追加できます。たとえば、以下に示すリソースは Basalt ビルドにのみ含まれます。

"resources": {
  "media": [
    {
      "type": "bitmap",
      "name": "BACKGROUND_IMAGE",
      "file": "images/background.png",
      "targetPlatforms": [
        "basalt"
      ]
    }
  ]
}
You need JavaScript enabled to read and post comments.