@next2d/display 1.14.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
+ import { Graphics } from "./Graphics";
3
+ import { SoundTransform } from "@next2d/media";
4
+ import { Rectangle, Point } from "@next2d/geom";
5
+ import { SpriteImpl, DropTargetImpl, DictionaryTagImpl, ParentImpl, MovieClipCharacterImpl } from "@next2d/interface";
6
+ /**
7
+ * Sprite クラスは、表示リストの基本的要素です。
8
+ * グラフィックを表示でき、子を持つこともできる表示リストノードです。
9
+ *
10
+ * The Sprite class is a basic display list building block:
11
+ * a display list node that can display graphics and can also contain children.
12
+ *
13
+ * @class
14
+ * @memberOf next2d.display
15
+ * @extends DisplayObjectContainer
16
+ */
17
+ export declare class Sprite extends DisplayObjectContainer {
18
+ protected _$buttonMode: boolean;
19
+ protected _$hitArea: SpriteImpl<any> | null;
20
+ protected _$soundTransform: SoundTransform | null;
21
+ protected _$graphics: Graphics | null;
22
+ protected _$useHandCursor: boolean;
23
+ /**
24
+ * @constructor
25
+ * @public
26
+ */
27
+ constructor();
28
+ /**
29
+ * @description 指定されたクラスのストリングを返します。
30
+ * Returns the string representation of the specified class.
31
+ *
32
+ * @return {string}
33
+ * @default [class Sprite]
34
+ * @method
35
+ * @static
36
+ */
37
+ static toString(): string;
38
+ /**
39
+ * @description 指定されたクラスの空間名を返します。
40
+ * Returns the space name of the specified class.
41
+ *
42
+ * @return {string}
43
+ * @default next2d.display.Sprite
44
+ * @const
45
+ * @static
46
+ */
47
+ static get namespace(): string;
48
+ /**
49
+ * @description 指定されたオブジェクトのストリングを返します。
50
+ * Returns the string representation of the specified object.
51
+ *
52
+ * @return {string}
53
+ * @default [object Sprite]
54
+ * @method
55
+ * @public
56
+ */
57
+ toString(): string;
58
+ /**
59
+ * @description 指定されたオブジェクトの空間名を返します。
60
+ * Returns the space name of the specified object.
61
+ *
62
+ * @return {string}
63
+ * @default next2d.display.Sprite
64
+ * @const
65
+ * @public
66
+ */
67
+ get namespace(): string;
68
+ /**
69
+ * @description このスプライトのボタンモードを指定します。
70
+ * Specifies the button mode of this sprite.
71
+ *
72
+ * @member {boolean}
73
+ * @default false
74
+ * @public
75
+ */
76
+ get buttonMode(): boolean;
77
+ set buttonMode(button_mode: boolean);
78
+ /**
79
+ * @description スプライトのドラッグ先またはスプライトがドロップされた先の表示オブジェクトを指定します。
80
+ * Specifies the display object over which the sprite is being dragged,
81
+ * or on which the sprite was dropped.
82
+ *
83
+ * @member {DisplayObject|null}
84
+ * @readonly
85
+ * @public
86
+ */
87
+ get dropTarget(): DropTargetImpl;
88
+ /**
89
+ * @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
90
+ * Specifies the Graphics object that belongs to this sprite
91
+ * where vector drawing commands can occur.
92
+ *
93
+ * @member {Graphics}
94
+ * @readonly
95
+ * @public
96
+ */
97
+ get graphics(): Graphics;
98
+ /**
99
+ * @description スプライトのヒット領域となる別のスプライトを指定します。
100
+ * Designates another sprite to serve as the hit area for a sprite.
101
+ *
102
+ * @member {Sprite|null}
103
+ * @public
104
+ */
105
+ get hitArea(): SpriteImpl<any> | null;
106
+ set hitArea(hit_area: SpriteImpl<any> | null);
107
+ /**
108
+ * @description このスプライト内のサウンドを制御します。
109
+ * Controls sound within this sprite.
110
+ *
111
+ * @member {SoundTransform}
112
+ * @public
113
+ */
114
+ get soundTransform(): SoundTransform;
115
+ set soundTransform(sound_transform: SoundTransform | null);
116
+ /**
117
+ * @description buttonMode プロパティが true に設定されたスプライト上にポインターが移動したときに、
118
+ * 指差しハンドポインター(ハンドカーソル)を表示するかどうかを示すブール値です。
119
+ * A Boolean value that indicates whether the pointing hand (hand cursor)
120
+ * appears when the pointer rolls over a sprite
121
+ * in which the buttonMode property is set to true.
122
+ *
123
+ * @member {boolean}
124
+ * @default true
125
+ * @public
126
+ */
127
+ get useHandCursor(): boolean;
128
+ set useHandCursor(use_hand_cursor: boolean);
129
+ /**
130
+ * @description 指定されたスプライトをユーザーがドラッグできるようにします。
131
+ * Lets the user drag the specified sprite.
132
+ *
133
+ * @param {boolean} [lock_center=false]
134
+ * @param {Rectangle} [bounds=null]
135
+ * @return {void}
136
+ * @method
137
+ * @public
138
+ */
139
+ startDrag(lock_center?: boolean, bounds?: Rectangle | null): void;
140
+ /**
141
+ * @description startDrag() メソッドを終了します。
142
+ * Ends the startDrag() method.
143
+ *
144
+ * @return void
145
+ * @method
146
+ * @public
147
+ */
148
+ stopDrag(): void;
149
+ /**
150
+ * @param {object} character
151
+ * @return {void}
152
+ * @method
153
+ * @private
154
+ */
155
+ _$sync(character: MovieClipCharacterImpl): void;
156
+ /**
157
+ * @param {object} tag
158
+ * @param {DisplayObjectContainer} parent
159
+ * @return {object}
160
+ * @method
161
+ * @private
162
+ */
163
+ _$build(tag: DictionaryTagImpl, parent: ParentImpl<any>): MovieClipCharacterImpl;
164
+ /**
165
+ * @return {Point}
166
+ * @method
167
+ * @private
168
+ */
169
+ _$dragMousePoint(): Point;
170
+ }
package/dist/Sprite.js ADDED
@@ -0,0 +1,280 @@
1
+ import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
+ import { Graphics } from "./Graphics";
3
+ import { SoundTransform } from "@next2d/media";
4
+ import { $currentMousePoint, $dragRules, $dropTarget, $rendererWorker, $setDropTarget } from "@next2d/util";
5
+ /**
6
+ * Sprite クラスは、表示リストの基本的要素です。
7
+ * グラフィックを表示でき、子を持つこともできる表示リストノードです。
8
+ *
9
+ * The Sprite class is a basic display list building block:
10
+ * a display list node that can display graphics and can also contain children.
11
+ *
12
+ * @class
13
+ * @memberOf next2d.display
14
+ * @extends DisplayObjectContainer
15
+ */
16
+ export class Sprite extends DisplayObjectContainer {
17
+ /**
18
+ * @constructor
19
+ * @public
20
+ */
21
+ constructor() {
22
+ super();
23
+ /**
24
+ * @type {boolean}
25
+ * @default false
26
+ * @private
27
+ */
28
+ this._$buttonMode = false;
29
+ /**
30
+ * @type {Sprite|null}
31
+ * @default null
32
+ * @private
33
+ */
34
+ this._$hitArea = null;
35
+ /**
36
+ * @type {SoundTransform}
37
+ * @default null
38
+ * @private
39
+ */
40
+ this._$soundTransform = null;
41
+ /**
42
+ * @type {boolean}
43
+ * @default true
44
+ * @private
45
+ */
46
+ this._$useHandCursor = true;
47
+ /**
48
+ * @type {Graphics|null}
49
+ * @default null
50
+ * @private
51
+ */
52
+ this._$graphics = null;
53
+ }
54
+ /**
55
+ * @description 指定されたクラスのストリングを返します。
56
+ * Returns the string representation of the specified class.
57
+ *
58
+ * @return {string}
59
+ * @default [class Sprite]
60
+ * @method
61
+ * @static
62
+ */
63
+ static toString() {
64
+ return "[class Sprite]";
65
+ }
66
+ /**
67
+ * @description 指定されたクラスの空間名を返します。
68
+ * Returns the space name of the specified class.
69
+ *
70
+ * @return {string}
71
+ * @default next2d.display.Sprite
72
+ * @const
73
+ * @static
74
+ */
75
+ static get namespace() {
76
+ return "next2d.display.Sprite";
77
+ }
78
+ /**
79
+ * @description 指定されたオブジェクトのストリングを返します。
80
+ * Returns the string representation of the specified object.
81
+ *
82
+ * @return {string}
83
+ * @default [object Sprite]
84
+ * @method
85
+ * @public
86
+ */
87
+ toString() {
88
+ return "[object Sprite]";
89
+ }
90
+ /**
91
+ * @description 指定されたオブジェクトの空間名を返します。
92
+ * Returns the space name of the specified object.
93
+ *
94
+ * @return {string}
95
+ * @default next2d.display.Sprite
96
+ * @const
97
+ * @public
98
+ */
99
+ get namespace() {
100
+ return "next2d.display.Sprite";
101
+ }
102
+ /**
103
+ * @description このスプライトのボタンモードを指定します。
104
+ * Specifies the button mode of this sprite.
105
+ *
106
+ * @member {boolean}
107
+ * @default false
108
+ * @public
109
+ */
110
+ get buttonMode() {
111
+ return this._$buttonMode;
112
+ }
113
+ set buttonMode(button_mode) {
114
+ this._$buttonMode = !!button_mode;
115
+ }
116
+ /**
117
+ * @description スプライトのドラッグ先またはスプライトがドロップされた先の表示オブジェクトを指定します。
118
+ * Specifies the display object over which the sprite is being dragged,
119
+ * or on which the sprite was dropped.
120
+ *
121
+ * @member {DisplayObject|null}
122
+ * @readonly
123
+ * @public
124
+ */
125
+ get dropTarget() {
126
+ return $dropTarget;
127
+ }
128
+ /**
129
+ * @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
130
+ * Specifies the Graphics object that belongs to this sprite
131
+ * where vector drawing commands can occur.
132
+ *
133
+ * @member {Graphics}
134
+ * @readonly
135
+ * @public
136
+ */
137
+ get graphics() {
138
+ if (!this._$graphics) {
139
+ this._$graphics = new Graphics(this);
140
+ }
141
+ return this._$graphics;
142
+ }
143
+ /**
144
+ * @description スプライトのヒット領域となる別のスプライトを指定します。
145
+ * Designates another sprite to serve as the hit area for a sprite.
146
+ *
147
+ * @member {Sprite|null}
148
+ * @public
149
+ */
150
+ get hitArea() {
151
+ return this._$hitArea;
152
+ }
153
+ set hitArea(hit_area) {
154
+ // reset
155
+ if (this._$hitArea) {
156
+ this._$hitArea._$hitObject = null;
157
+ }
158
+ this._$hitArea = hit_area;
159
+ if (hit_area) {
160
+ hit_area._$hitObject = this;
161
+ }
162
+ }
163
+ /**
164
+ * @description このスプライト内のサウンドを制御します。
165
+ * Controls sound within this sprite.
166
+ *
167
+ * @member {SoundTransform}
168
+ * @public
169
+ */
170
+ get soundTransform() {
171
+ if (!this._$soundTransform) {
172
+ this._$soundTransform = new SoundTransform();
173
+ }
174
+ return this._$soundTransform;
175
+ }
176
+ set soundTransform(sound_transform) {
177
+ this._$soundTransform = sound_transform;
178
+ }
179
+ /**
180
+ * @description buttonMode プロパティが true に設定されたスプライト上にポインターが移動したときに、
181
+ * 指差しハンドポインター(ハンドカーソル)を表示するかどうかを示すブール値です。
182
+ * A Boolean value that indicates whether the pointing hand (hand cursor)
183
+ * appears when the pointer rolls over a sprite
184
+ * in which the buttonMode property is set to true.
185
+ *
186
+ * @member {boolean}
187
+ * @default true
188
+ * @public
189
+ */
190
+ get useHandCursor() {
191
+ return this._$useHandCursor;
192
+ }
193
+ set useHandCursor(use_hand_cursor) {
194
+ this._$useHandCursor = use_hand_cursor;
195
+ }
196
+ /**
197
+ * @description 指定されたスプライトをユーザーがドラッグできるようにします。
198
+ * Lets the user drag the specified sprite.
199
+ *
200
+ * @param {boolean} [lock_center=false]
201
+ * @param {Rectangle} [bounds=null]
202
+ * @return {void}
203
+ * @method
204
+ * @public
205
+ */
206
+ startDrag(lock_center = false, bounds = null) {
207
+ let x = 0;
208
+ let y = 0;
209
+ if (!lock_center) {
210
+ const point = this._$dragMousePoint();
211
+ x = this.x - point.x;
212
+ y = this.y - point.y;
213
+ }
214
+ $setDropTarget(this);
215
+ $dragRules.lock = lock_center;
216
+ $dragRules.position.x = x;
217
+ $dragRules.position.y = y;
218
+ $dragRules.bounds = bounds;
219
+ }
220
+ /**
221
+ * @description startDrag() メソッドを終了します。
222
+ * Ends the startDrag() method.
223
+ *
224
+ * @return void
225
+ * @method
226
+ * @public
227
+ */
228
+ stopDrag() {
229
+ // reset
230
+ $setDropTarget(null);
231
+ $dragRules.lock = false;
232
+ $dragRules.position.x = 0;
233
+ $dragRules.position.y = 0;
234
+ $dragRules.bounds = null;
235
+ }
236
+ /**
237
+ * @param {object} character
238
+ * @return {void}
239
+ * @method
240
+ * @private
241
+ */
242
+ _$sync(character) {
243
+ if ($rendererWorker && this._$stage) {
244
+ this._$createWorkerInstance();
245
+ }
246
+ this._$controller = character.controller;
247
+ this._$dictionary = character.dictionary;
248
+ this._$placeMap = character.placeMap;
249
+ this._$placeObjects = character.placeObjects;
250
+ }
251
+ /**
252
+ * @param {object} tag
253
+ * @param {DisplayObjectContainer} parent
254
+ * @return {object}
255
+ * @method
256
+ * @private
257
+ */
258
+ _$build(tag, parent) {
259
+ const character = this
260
+ ._$baseBuild(tag, parent);
261
+ if ($rendererWorker && this._$stage) {
262
+ this._$createWorkerInstance();
263
+ }
264
+ this._$controller = character.controller;
265
+ this._$dictionary = character.dictionary;
266
+ this._$placeMap = character.placeMap;
267
+ this._$placeObjects = character.placeObjects;
268
+ return character;
269
+ }
270
+ /**
271
+ * @return {Point}
272
+ * @method
273
+ * @private
274
+ */
275
+ _$dragMousePoint() {
276
+ return this._$parent
277
+ ? this._$parent.globalToLocal($currentMousePoint())
278
+ : this.globalToLocal($currentMousePoint());
279
+ }
280
+ }
@@ -0,0 +1,164 @@
1
+ import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
+ import { Player } from "@next2d/core";
3
+ import { DisplayObjectImpl } from "@next2d/interface";
4
+ /**
5
+ * Stage クラスはメイン描画領域を表します。
6
+ * The Stage class represents the main drawing area.
7
+ *
8
+ * @class
9
+ * @memberOf next2d.display
10
+ * @extends DisplayObjectContainer
11
+ */
12
+ export declare class Stage extends DisplayObjectContainer {
13
+ _$player: Player | null;
14
+ _$invalidate: boolean;
15
+ private _$color;
16
+ _$frameRate: number;
17
+ /**
18
+ * @constructor
19
+ * @public
20
+ */
21
+ constructor();
22
+ /**
23
+ * @description 指定されたクラスのストリングを返します。
24
+ * Returns the string representation of the specified class.
25
+ *
26
+ * @return {string}
27
+ * @default [class Stage]
28
+ * @method
29
+ * @static
30
+ */
31
+ static toString(): string;
32
+ /**
33
+ * @description 指定されたクラスの空間名を返します。
34
+ * Returns the space name of the specified class.
35
+ *
36
+ * @return {string}
37
+ * @default next2d.display.Stage
38
+ * @const
39
+ * @static
40
+ */
41
+ static get namespace(): string;
42
+ /**
43
+ * @description 指定されたオブジェクトのストリングを返します。
44
+ * Returns the string representation of the specified object.
45
+ *
46
+ * @return {string}
47
+ * @default [object Stage]
48
+ * @method
49
+ * @public
50
+ */
51
+ toString(): string;
52
+ /**
53
+ * @description 指定されたオブジェクトの空間名を返します。
54
+ * Returns the space name of the specified object.
55
+ *
56
+ * @return {string}
57
+ * @default next2d.display.Stage
58
+ * @const
59
+ * @public
60
+ */
61
+ get namespace(): string;
62
+ /**
63
+ * @description 背景色です。
64
+ * background color.
65
+ *
66
+ * @member {number}
67
+ * @public
68
+ */
69
+ get color(): number;
70
+ set color(color: number);
71
+ /**
72
+ * @description ステージのフレームレートを取得または設定します。
73
+ * Gets and sets the frame rate of the stage.
74
+ *
75
+ * @member {number}
76
+ * @public
77
+ */
78
+ get frameRate(): number;
79
+ set frameRate(frame_rate: number);
80
+ /**
81
+ * @description Player オブジェクトを返します。
82
+ * Returns a Player object.
83
+ *
84
+ * @member {Player}
85
+ * @readonly
86
+ * @public
87
+ */
88
+ get player(): Player | null;
89
+ /**
90
+ * @description 現在のCanvasの高さをピクセル単位で指定します。
91
+ * Specifies the height of the current Canvas in pixels.
92
+ *
93
+ * @member {number}
94
+ * @readonly
95
+ * @public
96
+ */
97
+ get canvasHeight(): number;
98
+ /**
99
+ * @description 現在のCanvasの幅をピクセル単位で指定します。
100
+ * Specifies the width of the current Canvas in pixels.
101
+ *
102
+ * @member {number}
103
+ * @readonly
104
+ * @public
105
+ */
106
+ get canvasWidth(): number;
107
+ /**
108
+ * @description 現在のStageの高さをピクセル単位で指定します。
109
+ * Specifies the height of the current Stage in pixels.
110
+ *
111
+ * @member {number}
112
+ * @readonly
113
+ * @public
114
+ */
115
+ get currentStageHeight(): number;
116
+ /**
117
+ * @description 現在のStageの幅をピクセル単位で指定します。
118
+ * Specifies the width of the current Stage in pixels.
119
+ *
120
+ * @member {number}
121
+ * @readonly
122
+ * @public
123
+ */
124
+ get currentStageWidth(): number;
125
+ /**
126
+ * @description 初期設定したステージの高さをピクセル単位で指定します。
127
+ * Specifies the height of the initially set stage in pixels.
128
+ *
129
+ * @member {number}
130
+ * @readonly
131
+ * @public
132
+ */
133
+ get stageHeight(): number;
134
+ /**
135
+ * @description 初期設定したステージの幅をピクセル単位で指定します。
136
+ * Specifies the width of the initially set stage in pixels.
137
+ *
138
+ * @member {number}
139
+ * @readonly
140
+ * @public
141
+ */
142
+ get stageWidth(): number;
143
+ /**
144
+ * @description 表示リストをレンダリングする必要のある次の機会に、
145
+ * 表示オブジェクトに警告するようランタイムに通知します。
146
+ * (例えば、再生ヘッドを新しいフレームに進める場合などです。)
147
+ * Calling the invalidate() method signals runtimes
148
+ * to alert display objects on the next opportunity
149
+ * it has to render the display list.
150
+ * (for example, when the playhead advances to a new frame)
151
+ *
152
+ * @return {void}
153
+ * @method
154
+ * @public
155
+ */
156
+ invalidate(): void;
157
+ /**
158
+ * @param {DisplayObject} child
159
+ * @return {DisplayObject}
160
+ * @method
161
+ * @private
162
+ */
163
+ _$addChild(child: DisplayObjectImpl<any>): DisplayObjectImpl<any>;
164
+ }