@makefully/platypus 4.1.4 → 4.1.6
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.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -2
- package/lib/platypus.js +1 -1
- package/package.json +7 -2
- package/src/AABB.js +685 -0
- package/src/ActionState.js +121 -0
- package/src/AssetManager.js +206 -0
- package/src/CollisionData.js +96 -0
- package/src/CollisionDataContainer.js +127 -0
- package/src/CollisionShape.js +315 -0
- package/src/Component.js +231 -0
- package/src/Data.js +64 -0
- package/src/DataMap.js +204 -0
- package/src/Entity.js +404 -0
- package/src/EntityLinker.js +113 -0
- package/src/EventHandler.js +115 -0
- package/src/EventHandlerList.js +251 -0
- package/src/Game.js +840 -0
- package/src/Gamepad.js +175 -0
- package/src/ID3CaptionPlayer.js +61 -0
- package/src/Messenger.js +365 -0
- package/src/PIXIAnimation.js +622 -0
- package/src/RandomSet.js +140 -0
- package/src/SFXPlayer.js +120 -0
- package/src/StateMap.js +252 -0
- package/src/Storage.js +152 -0
- package/src/TickerClient.js +48 -0
- package/src/TickerServer.js +23 -0
- package/src/TimeEvent.js +50 -0
- package/src/TimeEventList.js +100 -0
- package/src/VOPlayer.js +684 -0
- package/src/Vector.js +702 -0
- package/src/components/AIChaser.js +161 -0
- package/src/components/AIPacer.js +107 -0
- package/src/components/AudioMusic.js +151 -0
- package/src/components/AudioSFX.js +673 -0
- package/src/components/AudioVO.js +301 -0
- package/src/components/CollisionBasic.js +826 -0
- package/src/components/CollisionFilter.js +74 -0
- package/src/components/CollisionGroup.js +448 -0
- package/src/components/CollisionTiles.js +608 -0
- package/src/components/ComponentSwitcher.js +173 -0
- package/src/components/ControllerInput.js +65 -0
- package/src/components/Counter.js +165 -0
- package/src/components/EntityCamera.js +215 -0
- package/src/components/EntityContainer.js +549 -0
- package/src/components/EntityController.js +541 -0
- package/src/components/HandlerCamera.js +1052 -0
- package/src/components/HandlerCollision.js +1318 -0
- package/src/components/HandlerController.js +291 -0
- package/src/components/HandlerLogic.js +394 -0
- package/src/components/HandlerRender.js +217 -0
- package/src/components/Interactive.js +502 -0
- package/src/components/LevelBuilder.js +524 -0
- package/src/components/LogicAngularMovement.js +154 -0
- package/src/components/LogicAttachment.js +265 -0
- package/src/components/LogicButton.js +466 -0
- package/src/components/LogicCarrier.js +39 -0
- package/src/components/LogicDestroyMe.js +58 -0
- package/src/components/LogicDirectionalMovement.js +325 -0
- package/src/components/LogicDragDrop.js +371 -0
- package/src/components/LogicImpactLaunch.js +144 -0
- package/src/components/LogicPacingPlatform.js +64 -0
- package/src/components/LogicPortable.js +112 -0
- package/src/components/LogicPortal.js +115 -0
- package/src/components/LogicPushable.js +98 -0
- package/src/components/LogicRebounder.js +136 -0
- package/src/components/LogicRegionSpawner.js +139 -0
- package/src/components/LogicRotationalMovement.js +205 -0
- package/src/components/LogicSpawner.js +159 -0
- package/src/components/LogicStateMachine.js +382 -0
- package/src/components/LogicSwitch.js +77 -0
- package/src/components/LogicTeleportee.js +68 -0
- package/src/components/LogicTeleporter.js +93 -0
- package/src/components/LogicTimer.js +178 -0
- package/src/components/LogicWindUpRacer.js +179 -0
- package/src/components/Motion.js +371 -0
- package/src/components/Mover.js +566 -0
- package/src/components/Node.js +289 -0
- package/src/components/NodeMap.js +295 -0
- package/src/components/NodeResident.js +636 -0
- package/src/components/Orientation.js +697 -0
- package/src/components/RandomEvents.js +73 -0
- package/src/components/RelativePosition.js +204 -0
- package/src/components/RelayFamily.js +106 -0
- package/src/components/RelayGame.js +53 -0
- package/src/components/RelayLinker.js +94 -0
- package/src/components/RelayParent.js +57 -0
- package/src/components/RelaySelf.js +55 -0
- package/src/components/Render.js +178 -0
- package/src/components/RenderAnimator.js +275 -0
- package/src/components/RenderContainer.js +646 -0
- package/src/components/RenderDebug.js +319 -0
- package/src/components/RenderDestroyMe.js +59 -0
- package/src/components/RenderLottie.js +149 -0
- package/src/components/RenderProgress.js +120 -0
- package/src/components/RenderSpine.js +833 -0
- package/src/components/RenderSprite.js +527 -0
- package/src/components/RenderText.js +147 -0
- package/src/components/RenderTiles.js +1391 -0
- package/src/components/SceneChanger.js +128 -0
- package/src/components/TiledLoader.js +1451 -0
- package/src/components/Timeline.js +314 -0
- package/src/components/Tutorial.js +267 -0
- package/src/components/Tween.js +296 -0
- package/src/components/VoiceOver.js +373 -0
- package/src/components/XHR.js +129 -0
- package/src/components/index.js +79 -0
- package/src/factory.js +305 -0
- package/src/index.js +159 -0
- package/src/mixins/PIXI.Graphics.js +41 -0
- package/src/platypus.css +68 -0
- package/src/sayHello.js +50 -0
- package/src/shapes/Capsule.js +74 -0
- package/src/shapes/Circle.js +43 -0
- package/src/shapes/Ellipse.js +117 -0
- package/src/shapes/Point.js +191 -0
- package/src/shapes/Polygon.js +112 -0
- package/src/shapes/Polyline.js +97 -0
- package/src/shapes/Rectangle.js +78 -0
- package/src/shapes/RoundedRectangle.js +33 -0
- package/src/shapes/Segment.js +346 -0
- package/src/shapes/adjustedXY.js +19 -0
- package/src/shapes/castFromBox2D.js +92 -0
- package/src/shapes/castFromObject.js +53 -0
- package/src/shapes/castFromPixiGraphics.js +6 -0
- package/src/shapes/castFromPixiShape.js +89 -0
- package/src/shapes/castToBox2D.js +190 -0
- package/src/shapes/castToPixiGraphics.js +100 -0
- package/src/shapes/castToPixiShape.js +61 -0
- package/src/shapes/checkPointsMap.js +313 -0
- package/src/shapes/index.js +35 -0
- package/src/utils/array.js +73 -0
- package/src/utils/string.js +39 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/* global platypus */
|
|
2
|
+
import {Container} from 'pixi.js';
|
|
3
|
+
import Data from '../Data.js';
|
|
4
|
+
import Interactive from './Interactive.js';
|
|
5
|
+
import createComponentClass from '../factory.js';
|
|
6
|
+
|
|
7
|
+
export default (function () {
|
|
8
|
+
return createComponentClass(/** @lends platypus.components.HandlerRender.prototype */{
|
|
9
|
+
|
|
10
|
+
id: "HandlerRender",
|
|
11
|
+
|
|
12
|
+
properties: {
|
|
13
|
+
/**
|
|
14
|
+
* Defines whether the entity will respond to touch and click events. Setting this value will create an Interactive component on this entity with these properties. For example:
|
|
15
|
+
*
|
|
16
|
+
* "interactive": {
|
|
17
|
+
* "hover": false,
|
|
18
|
+
* "hitArea": {
|
|
19
|
+
* "x": 10,
|
|
20
|
+
* "y": 10,
|
|
21
|
+
* "width": 40,
|
|
22
|
+
* "height": 40
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @property interactive
|
|
27
|
+
* @type Boolean|Object
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
interactive: false
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
publicProperties: {
|
|
34
|
+
/**
|
|
35
|
+
* This is the container holding all children's disply objects for this layer. It's an available property on the layer entity.
|
|
36
|
+
*
|
|
37
|
+
* @property worldContainer
|
|
38
|
+
* @type PIXI.Container
|
|
39
|
+
* @default null
|
|
40
|
+
*/
|
|
41
|
+
worldContainer: null,
|
|
42
|
+
/**
|
|
43
|
+
* A multiplier that alters the speed at which the game is running. This is achieved by scaling the delta time in each tick.
|
|
44
|
+
* Defaults to 1. Values < 1 will slow down the rendering, > 1 will speed it up.
|
|
45
|
+
*
|
|
46
|
+
* @property timeMultiplier
|
|
47
|
+
* @type number
|
|
48
|
+
* @default 1
|
|
49
|
+
*/
|
|
50
|
+
timeMultiplier: 1
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A component that handles updating the render components on entities that are rendering via PIXI. Calls 'handle-render on children entities every tick. Also initializes handlers for mouse events on the layer level.
|
|
55
|
+
*
|
|
56
|
+
* @memberof platypus.components
|
|
57
|
+
* @uses platypus.Component
|
|
58
|
+
* @constructs
|
|
59
|
+
* @listens platypus.Entity#child-entity-added
|
|
60
|
+
* @listens platypus.Entity#load
|
|
61
|
+
* @listens platypus.Entity#pause-render
|
|
62
|
+
* @listens platypus.Entity#render-update
|
|
63
|
+
* @listens platypus.Entity#set-parent-render-container
|
|
64
|
+
* @listens platypus.Entity#tick
|
|
65
|
+
* @listens platypus.Entity#unpause-render
|
|
66
|
+
* @fires platypus.Entity#handle-render-load
|
|
67
|
+
* @fires platypus.Entity#handle-render
|
|
68
|
+
* @fires platypus.Entity#input-on
|
|
69
|
+
* @fires platypus.Entity#render-paused
|
|
70
|
+
* @fires platypus.Entity#render-unpaused
|
|
71
|
+
* @fires platypus.Entity#render-world
|
|
72
|
+
*/
|
|
73
|
+
initialize: function () {
|
|
74
|
+
let definition = null;
|
|
75
|
+
|
|
76
|
+
this.worldContainer = this.worldContainer || new Container();
|
|
77
|
+
this.worldContainer.sortableChildren = true;
|
|
78
|
+
this.worldContainer.label = '';
|
|
79
|
+
|
|
80
|
+
if (this.interactive) {
|
|
81
|
+
definition = Data.setUp(
|
|
82
|
+
'container', this.worldContainer,
|
|
83
|
+
'hitArea', this.interactive.hitArea,
|
|
84
|
+
'hover', this.interactive.hover,
|
|
85
|
+
'relativeToSelf', true
|
|
86
|
+
);
|
|
87
|
+
this.owner.addComponent(new Interactive(this.owner, definition));
|
|
88
|
+
definition.recycle();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.renderMessage = Data.setUp(
|
|
92
|
+
'delta', 0,
|
|
93
|
+
'container', this.worldContainer,
|
|
94
|
+
'tick', null
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
events: {
|
|
99
|
+
"load": function () {
|
|
100
|
+
/**
|
|
101
|
+
* Once the entity is loaded, this component triggers "render-world" to notify other components about the entities' display container.
|
|
102
|
+
*
|
|
103
|
+
* @event platypus.Entity#render-world
|
|
104
|
+
* @param data {Object}
|
|
105
|
+
* @param data.world {PIXI.Container} Contains entities to be rendered.
|
|
106
|
+
*/
|
|
107
|
+
this.owner.triggerEvent('render-world', {
|
|
108
|
+
world: this.worldContainer
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This event is triggered once HandlerRender is ready to handle interactivity.
|
|
113
|
+
*
|
|
114
|
+
* @event platypus.Entity#input-on
|
|
115
|
+
*/
|
|
116
|
+
this.owner.triggerEvent('input-on');
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
"child-entity-added": function (entity) {
|
|
120
|
+
/**
|
|
121
|
+
* Triggered on an entity added to the parent.
|
|
122
|
+
*
|
|
123
|
+
* @event platypus.Entity#handle-render-load
|
|
124
|
+
* @param data {Object}
|
|
125
|
+
* @param data.delta {Number} The delta time for this tick.
|
|
126
|
+
* @param data.container {PIXI.Container} The display Container the entities display objects should be added to.
|
|
127
|
+
*/
|
|
128
|
+
entity.triggerEvent('handle-render-load', this.renderMessage);
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
"pause-render": function (timeData) {
|
|
132
|
+
if (timeData && timeData.time) {
|
|
133
|
+
this.paused = timeData.time;
|
|
134
|
+
} else {
|
|
135
|
+
this.paused = -1;
|
|
136
|
+
}
|
|
137
|
+
if (this.owner.triggerEventOnChildren) {
|
|
138
|
+
/**
|
|
139
|
+
* Notifies children entities that rendering updates have been paused.
|
|
140
|
+
*
|
|
141
|
+
* @event platypus.Entity#render-paused
|
|
142
|
+
*/
|
|
143
|
+
this.owner.triggerEventOnChildren('render-paused');
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
"unpause-render": function () {
|
|
148
|
+
this.paused = 0;
|
|
149
|
+
if (this.owner.triggerEventOnChildren) {
|
|
150
|
+
/**
|
|
151
|
+
* Notifies children entities that rendering updates have been unpaused.
|
|
152
|
+
*
|
|
153
|
+
* @event platypus.Entity#render-unpaused
|
|
154
|
+
*/
|
|
155
|
+
this.owner.triggerEventOnChildren('render-unpaused');
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
"tick": function (tick) {
|
|
160
|
+
if (this.paused > 0) {
|
|
161
|
+
this.paused -= tick.delta;
|
|
162
|
+
if (this.paused <= 0) {
|
|
163
|
+
this.paused = 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!this.paused) {
|
|
168
|
+
this.renderUpdate(tick);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
"render-update": function (tick) {
|
|
173
|
+
this.renderUpdate(tick);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
"set-parent-render-container": function (entity, container) {
|
|
177
|
+
this.setParentRenderContainer(entity, container);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
methods: {
|
|
181
|
+
renderUpdate: function (tick) {
|
|
182
|
+
const message = this.renderMessage;
|
|
183
|
+
|
|
184
|
+
message.gameDelta = (tick && tick.delta) || 0;
|
|
185
|
+
message.delta = message.gameDelta * this.timeMultiplier;
|
|
186
|
+
message.tick = tick;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Triggered every tick on owner and its children entities.
|
|
190
|
+
*
|
|
191
|
+
* @event platypus.Entity#handle-render
|
|
192
|
+
* @param data {Object}
|
|
193
|
+
* @param data.delta {Number} The delta time for this tick as manipulated by the timeMultiplier.
|
|
194
|
+
* @param data.gameDelta {Number} The delta time for this tick. Unmanipulated by the timeMultiplier. Use for components that should always run according to actual time.
|
|
195
|
+
* @param data.container {PIXI.Container} The display Container the entities display objects should be added to.
|
|
196
|
+
* @param data.tick {Object} Tick object from "tick" event.
|
|
197
|
+
*/
|
|
198
|
+
this.owner.triggerEvent('handle-render', message);
|
|
199
|
+
|
|
200
|
+
if (this.owner.triggerEventOnChildren) {
|
|
201
|
+
this.owner.triggerEventOnChildren('handle-render', message);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
setParentRenderContainer: function (entity, newContainer) {
|
|
206
|
+
platypus.debug.warn("HandlerRender: No longer required to call 'setParentRenderContainer' on layer - just call 'addToParentContainer' on entity.")
|
|
207
|
+
|
|
208
|
+
entity.addToParentContainer(newContainer);
|
|
209
|
+
},
|
|
210
|
+
destroy: function () {
|
|
211
|
+
this.worldContainer = null;
|
|
212
|
+
this.renderMessage.recycle();
|
|
213
|
+
this.renderMessage = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}());
|