canvasengine 1.3.0 → 2.0.1-beta.1
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/.cursorrules +0 -0
- package/.github/workflows/ci.yml +29 -0
- package/README.md +79 -0
- package/dist/compiler/vite.js +119 -0
- package/dist/compiler/vite.js.map +1 -0
- package/dist/index.d.ts +846 -0
- package/dist/index.js +3340 -0
- package/dist/index.js.map +1 -0
- package/index.d.ts +6 -0
- package/logo.png +0 -0
- package/package.json +84 -18
- package/src/compiler/grammar.pegjs +180 -0
- package/src/compiler/vite.ts +166 -0
- package/src/components/Canvas.ts +134 -0
- package/src/components/Container.ts +46 -0
- package/src/components/DisplayObject.ts +458 -0
- package/src/components/DrawMap/index.ts +65 -0
- package/src/components/Graphic.ts +147 -0
- package/src/components/NineSliceSprite.ts +46 -0
- package/src/components/ParticleEmitter.ts +39 -0
- package/src/components/Scene.ts +6 -0
- package/src/components/Sprite.ts +493 -0
- package/src/components/Text.ts +145 -0
- package/src/components/Tilemap/Tile.ts +79 -0
- package/src/components/Tilemap/TileGroup.ts +207 -0
- package/src/components/Tilemap/TileLayer.ts +163 -0
- package/src/components/Tilemap/TileSet.ts +41 -0
- package/src/components/Tilemap/index.ts +80 -0
- package/src/components/TilingSprite.ts +39 -0
- package/src/components/Viewport.ts +159 -0
- package/src/components/index.ts +12 -0
- package/src/components/types/DisplayObject.ts +68 -0
- package/src/components/types/MouseEvent.ts +3 -0
- package/src/components/types/Spritesheet.ts +389 -0
- package/src/components/types/index.ts +4 -0
- package/src/directives/Drag.ts +84 -0
- package/src/directives/KeyboardControls.ts +922 -0
- package/src/directives/Scheduler.ts +112 -0
- package/src/directives/Sound.ts +91 -0
- package/src/directives/Transition.ts +45 -0
- package/src/directives/ViewportCull.ts +40 -0
- package/src/directives/ViewportFollow.ts +26 -0
- package/src/directives/index.ts +7 -0
- package/src/engine/animation.ts +113 -0
- package/src/engine/bootstrap.ts +19 -0
- package/src/engine/directive.ts +23 -0
- package/src/engine/reactive.ts +379 -0
- package/src/engine/signal.ts +138 -0
- package/src/engine/trigger.ts +40 -0
- package/src/engine/utils.ts +135 -0
- package/src/hooks/addContext.ts +6 -0
- package/src/hooks/useProps.ts +155 -0
- package/src/hooks/useRef.ts +21 -0
- package/src/index.ts +14 -0
- package/src/presets/Bar.ts +89 -0
- package/src/presets/Button.ts +0 -0
- package/src/presets/Joystick.ts +286 -0
- package/src/presets/NightAmbiant.ts +122 -0
- package/src/presets/Particle.ts +53 -0
- package/src/utils/Ease.ts +33 -0
- package/src/utils/RadialGradient.ts +86 -0
- package/starter/assets/logo.png +0 -0
- package/starter/components/app.ce +18 -0
- package/starter/components/hello.ce +35 -0
- package/starter/index.html +21 -0
- package/starter/main.ts +6 -0
- package/starter/package.json +20 -0
- package/starter/tsconfig.json +32 -0
- package/starter/vite.config.ts +12 -0
- package/tsconfig.json +32 -0
- package/tsconfig.node.json +10 -0
- package/tsup.config.ts +28 -0
- package/vitest.config.ts +12 -0
- package/.gitattributes +0 -22
- package/.npmignore +0 -163
- package/canvasengine-1.3.0.all.min.js +0 -21
- package/canvasengine.js +0 -5802
- package/core/DB.js +0 -24
- package/core/ModelServer.js +0 -348
- package/core/Users.js +0 -190
- package/core/engine-common.js +0 -952
- package/doc/cocoonjs.md +0 -36
- package/doc/doc-lang.yml +0 -43
- package/doc/doc-router.yml +0 -14
- package/doc/doc-tuto.yml +0 -9
- package/doc/doc.yml +0 -39
- package/doc/element.md +0 -37
- package/doc/entity.md +0 -90
- package/doc/extend.md +0 -47
- package/doc/get_started.md +0 -19
- package/doc/images/entity.png +0 -0
- package/doc/multitouch.md +0 -58
- package/doc/nodejs.md +0 -142
- package/doc/scene.md +0 -44
- package/doc/text.md +0 -156
- package/examples/server/client.html +0 -31
- package/examples/server/server.js +0 -16
- package/examples/tiled_server/client.html +0 -52
- package/examples/tiled_server/images/tiles_spritesheet.png +0 -0
- package/examples/tiled_server/server/map.json +0 -50
- package/examples/tiled_server/server/map.tmx +0 -16
- package/examples/tiled_server/server/server.js +0 -16
- package/extends/Animation.js +0 -910
- package/extends/Effect.js +0 -252
- package/extends/Gleed2d.js +0 -252
- package/extends/Hit.js +0 -1509
- package/extends/Input.js +0 -699
- package/extends/Marshal.js +0 -716
- package/extends/Scrolling.js +0 -388
- package/extends/Soundmanager2.js +0 -5466
- package/extends/Spritesheet.js +0 -196
- package/extends/Text.js +0 -366
- package/extends/Tiled.js +0 -403
- package/extends/Window.js +0 -575
- package/extends/gamepad.js +0 -397
- package/extends/socket.io.min.js +0 -2
- package/extends/swf/soundmanager2.swf +0 -0
- package/extends/swf/soundmanager2_debug.swf +0 -0
- package/extends/swf/soundmanager2_flash9.swf +0 -0
- package/extends/swf/soundmanager2_flash9_debug.swf +0 -0
- package/extends/swf/soundmanager2_flash_xdomain.zip +0 -0
- package/extends/workers/transition.js +0 -43
- package/index.js +0 -46
- package/license.txt +0 -19
- package/readme.md +0 -483
package/extends/Scrolling.js
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2012 by Samuel Ronce
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
THE SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
Class.create("Scrolling", {
|
|
24
|
-
main_el: null,
|
|
25
|
-
scroll_el: [],
|
|
26
|
-
scene: null,
|
|
27
|
-
freeze: false,
|
|
28
|
-
initialize: function(scene, tile_h, tile_w) {
|
|
29
|
-
this.scene = scene;
|
|
30
|
-
this.tile_h = tile_h;
|
|
31
|
-
this.tile_w = tile_w;
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
@doc scrolling/
|
|
35
|
-
@method setMainElement Defined the main element that will set the scrolling
|
|
36
|
-
@params {CanvasEngine.Element} main_el
|
|
37
|
-
*/
|
|
38
|
-
setMainElement: function(main_el) {
|
|
39
|
-
this.main_el = main_el;
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
@doc scrolling/
|
|
43
|
-
@method addScroll Add a layer scroll as the main element
|
|
44
|
-
@params {Object} params Parameters :
|
|
45
|
-
|
|
46
|
-
* element {CanvasEngine.Element}
|
|
47
|
-
* speed {Integer} Scrolling speed
|
|
48
|
-
* block {Boolean} (optional) Block scrolling on the edges of the map
|
|
49
|
-
* width {Integer} Width of element
|
|
50
|
-
* height {Integer} Height of element
|
|
51
|
-
|
|
52
|
-
@return {Object}
|
|
53
|
-
*/
|
|
54
|
-
addScroll: function(scroll_el) {
|
|
55
|
-
if (!scroll_el.screen_x) scroll_el.screen_x = 0;
|
|
56
|
-
if (!scroll_el.screen_y) scroll_el.screen_y = 0;
|
|
57
|
-
if (!scroll_el.parallax_x) scroll_el.parallax_x = 0;
|
|
58
|
-
if (!scroll_el.parallax_y) scroll_el.parallax_y = 0;
|
|
59
|
-
this.scroll_el.push(scroll_el);
|
|
60
|
-
if (this.main_el) this.setScreen(scroll_el);
|
|
61
|
-
return this.scroll_el[this.scroll_el.length-1];
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
@doc scrolling/
|
|
65
|
-
@method setScreen Center the camera on the X and Y positions assigned
|
|
66
|
-
@params {Object} scroll Scrolling settings. Identical to "addScroll" method
|
|
67
|
-
@params {Integer} x Position X (pixels)
|
|
68
|
-
@params {Integer} y Position Y (pixels)
|
|
69
|
-
*/
|
|
70
|
-
setScreen: function(scroll, real_x, real_y) {
|
|
71
|
-
var width, height;
|
|
72
|
-
if (!real_x && this.main_el) {
|
|
73
|
-
real_x = this.main_el.x;
|
|
74
|
-
real_y = this.main_el.y;
|
|
75
|
-
}
|
|
76
|
-
var canvas = this.scene.getCanvas();
|
|
77
|
-
if (real_x <= canvas.width/2) {
|
|
78
|
-
width = 0;
|
|
79
|
-
}
|
|
80
|
-
else if (real_x + canvas.width/2 >= scroll.width) {
|
|
81
|
-
width = -(scroll.width - canvas.width);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
width = -(real_x - canvas.width/2 + (canvas.width/2 % this.tile_w));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (real_y <= canvas.height/2) {
|
|
88
|
-
height = 0;
|
|
89
|
-
}
|
|
90
|
-
else if (real_y + canvas.height/2 >= scroll.height) {
|
|
91
|
-
height = -(scroll.height - canvas.height);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
height = -(real_y - canvas.height/2 + (canvas.height/2 % this.tile_h));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
scroll.element.x = width;
|
|
98
|
-
scroll.element.y = height;
|
|
99
|
-
|
|
100
|
-
var multiple_w = this.tile_w / scroll.speed;
|
|
101
|
-
var multiple_h = this.tile_h / scroll.speed;
|
|
102
|
-
scroll.element.x = Math.floor(scroll.element.x/multiple_w) * multiple_w ;
|
|
103
|
-
scroll.element.y = Math.floor(scroll.element.y/multiple_h) * multiple_h;
|
|
104
|
-
|
|
105
|
-
scroll.screen_x = Math.abs(scroll.element.x);
|
|
106
|
-
scroll.screen_y = Math.abs(scroll.element.y);
|
|
107
|
-
|
|
108
|
-
var m = this._multipleScreen(scroll.speed, scroll.screen_x, scroll.screen_y);
|
|
109
|
-
scroll.screen_x = m.x;
|
|
110
|
-
scroll.screen_y = m.y;
|
|
111
|
-
this.update();
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
_multipleScreen: function(speed, x, y) {
|
|
115
|
-
var multiple_w = this.tile_w / speed;
|
|
116
|
-
var multiple_h = this.tile_h / speed;
|
|
117
|
-
|
|
118
|
-
x = Math.floor(x/multiple_w) * multiple_w ;
|
|
119
|
-
y = Math.floor(y/multiple_h) * multiple_h;
|
|
120
|
-
return {x: x, y: y};
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
@doc scrolling/
|
|
124
|
-
@method update Update scrolling. A call loop
|
|
125
|
-
*/
|
|
126
|
-
update: function() {
|
|
127
|
-
|
|
128
|
-
var scroll, container;
|
|
129
|
-
var canvas = this.scene.getCanvas();
|
|
130
|
-
|
|
131
|
-
if (this.freeze) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!this.main_el) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
for (var i=0 ; i < this.scroll_el.length ; i++) {
|
|
140
|
-
|
|
141
|
-
scroll = this.scroll_el[i];
|
|
142
|
-
container = {x: scroll.element.x, y: scroll.element.y};
|
|
143
|
-
|
|
144
|
-
scroll.screen_x = this.main_el.x - canvas.width/2 + (canvas.width/2 % this.tile_w);
|
|
145
|
-
scroll.screen_y = this.main_el.y - canvas.height/2 + (canvas.height/2 % this.tile_h);
|
|
146
|
-
|
|
147
|
-
//container.y -= Math.abs(container.y) == scroll.screen_y ? 0 : Math.floor((scroll.screen_y < Math.abs(container.y) ? -this.tile_h : this.tile_h) / scroll.speed);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var absx = Math.abs(container.x);
|
|
152
|
-
var absy = Math.abs(container.y);
|
|
153
|
-
var speed_x = scroll.speed;
|
|
154
|
-
var speed_y = scroll.speed;
|
|
155
|
-
|
|
156
|
-
if (scroll.parallax) {
|
|
157
|
-
if (scroll.screen_x != scroll.parallax_x) {
|
|
158
|
-
if (scroll.screen_x > scroll.parallax_x) {
|
|
159
|
-
container.x -= speed_x;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
container.x += speed_x;
|
|
163
|
-
}
|
|
164
|
-
scroll.parallax_x = scroll.screen_x;
|
|
165
|
-
}
|
|
166
|
-
if (scroll.screen_y != scroll.parallax_y) {
|
|
167
|
-
if (scroll.screen_y > scroll.parallax_y) {
|
|
168
|
-
container.y -= speed_y;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
container.y += speed_y;
|
|
172
|
-
}
|
|
173
|
-
scroll.parallax_y = scroll.screen_y;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
if (absx != scroll.screen_x) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (scroll.screen_x > absx) {
|
|
181
|
-
if (absx > scroll.screen_x - speed_x) {
|
|
182
|
-
container.x = -scroll.screen_x;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
container.x -= speed_x;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else if (scroll.screen_x < absx) {
|
|
189
|
-
if (absx < scroll.screen_x + speed_x) {
|
|
190
|
-
container.x = -scroll.screen_x;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
container.x += speed_x;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
if (absy != scroll.screen_y) {
|
|
199
|
-
if (scroll.screen_y > absy) {
|
|
200
|
-
if (absy > scroll.screen_y - speed_y) {
|
|
201
|
-
container.y = -scroll.screen_y;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
container.y -= speed_y;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else if (scroll.screen_y < absy) {
|
|
208
|
-
if (absy < scroll.screen_y + speed_y) {
|
|
209
|
-
container.y = -scroll.screen_y;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
container.y += speed_y;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (scroll.block) {
|
|
221
|
-
if (container.x > 0) {
|
|
222
|
-
scroll.screen_x = container.x = 0;
|
|
223
|
-
}
|
|
224
|
-
else if (container.x + scroll.width < canvas.width) {
|
|
225
|
-
container.x = canvas.width - scroll.width;
|
|
226
|
-
container.x = this._multipleScreen(scroll.speed, container.x, 0).x;
|
|
227
|
-
scroll.screen_x = Math.abs(container.x);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (container.y > 0) {
|
|
231
|
-
scroll.screen_y = container.y = 0;
|
|
232
|
-
}
|
|
233
|
-
else if (container.y + scroll.height < canvas.height) {
|
|
234
|
-
container.y = canvas.height - scroll.height;
|
|
235
|
-
container.y = this._multipleScreen(scroll.speed, 0, container.y).y;
|
|
236
|
-
scroll.screen_y = Math.abs(container.y);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (canvas.width <= scroll.width) {
|
|
241
|
-
scroll.element.x = container.x >> 0;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (canvas.height <= scroll.height) {
|
|
245
|
-
scroll.element.y = container.y >> 0;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
@doc scrolling/
|
|
253
|
-
@method mouseScroll Performs the scrolling with the mouse.
|
|
254
|
-
@param {CanvasEngine.Element} clip Element containing the main element in the second parameter of this method. Indicate the dimensions of the element
|
|
255
|
-
@param {CanvasEngine.Element} content Element with the content to scroll. Indicate the dimensions of the element
|
|
256
|
-
@param {Object} callbacks (optinal) Different callbacks
|
|
257
|
-
|
|
258
|
-
* dragstart : When the user starts to scroll
|
|
259
|
-
* drag : When the user scrolls
|
|
260
|
-
* onTop : When the scroller reaches the top of the element
|
|
261
|
-
* onBottom : When the scroller reaches the bottom of the element
|
|
262
|
-
|
|
263
|
-
return {CanvasEngine.Scrolling}
|
|
264
|
-
@example
|
|
265
|
-
|
|
266
|
-
In method `ready`
|
|
267
|
-
|
|
268
|
-
var clip = this.createElement(300, 350), // Dimensions of the element
|
|
269
|
-
content = this.createElement(300, 800); // Dimensions of the element
|
|
270
|
-
|
|
271
|
-
var scroll = canvas.Scrolling.New(this);
|
|
272
|
-
scroll.mouseScroll(clip, content);
|
|
273
|
-
|
|
274
|
-
stage.append(clip);
|
|
275
|
-
|
|
276
|
-
*/
|
|
277
|
-
mouseScroll: function(clip, content, callbacks) {
|
|
278
|
-
|
|
279
|
-
callbacks = callbacks || {};
|
|
280
|
-
|
|
281
|
-
if (content.height < clip.height) {
|
|
282
|
-
clip.append(content);
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
var scroll_start = {};
|
|
287
|
-
var self = this;
|
|
288
|
-
|
|
289
|
-
content._forceEvent = true;
|
|
290
|
-
|
|
291
|
-
clip.beginPath();
|
|
292
|
-
clip.rect(0, 0, clip.width, clip.height);
|
|
293
|
-
clip.clip();
|
|
294
|
-
clip.closePath();
|
|
295
|
-
|
|
296
|
-
content.rect(0, 0, content.width, content.height);
|
|
297
|
-
|
|
298
|
-
content.on("dragstart", function(ev) {
|
|
299
|
-
scroll_start = this.offset();
|
|
300
|
-
scroll_start.time = new Date().getTime();
|
|
301
|
-
if (callbacks.dragstart) callbacks.dragstart.call(this, ev);
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
content.on("drag", function(ev) {
|
|
306
|
-
if(ev.direction == 'up' || ev.direction == 'left') {
|
|
307
|
-
ev.distance = -ev.distance;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
var delta = 1, y;
|
|
311
|
-
y = scroll_start.top + ev.distance * delta;
|
|
312
|
-
|
|
313
|
-
if (y >= 0) {
|
|
314
|
-
y = 0;
|
|
315
|
-
if (callbacks.onTop) callbacks.onTop.call(this, ev);
|
|
316
|
-
}
|
|
317
|
-
else if (clip.height >= (y + this.height)) {
|
|
318
|
-
y = -this.height + clip.height;
|
|
319
|
-
if (callbacks.onBottom) callbacks.onBottom.call(this, ev);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
this.y = y;
|
|
323
|
-
|
|
324
|
-
if (callbacks.drag) callbacks.drag.call(this, ev);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
content.on("dragend", function(ev) {
|
|
329
|
-
if (callbacks.dragend) callbacks.dragend.call(this, ev);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
clip.append(content);
|
|
333
|
-
|
|
334
|
-
return this;
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
@doc scrolling
|
|
341
|
-
@class Scrolling A side-scrolling game or side-scroller is a video game in which the gameplay action is viewed from a side-view camera angle, and the onscreen characters generally move from the left side of the screen to the right
|
|
342
|
-
|
|
343
|
-
http://en.wikipedia.org/wiki/Side-scrolling_video_game
|
|
344
|
-
|
|
345
|
-
@param {CanvasEngine.Scene} scene
|
|
346
|
-
@param {Integer} tile_h Height of the tile
|
|
347
|
-
@param {Integer} tile_w width of the tile
|
|
348
|
-
@example
|
|
349
|
-
|
|
350
|
-
var canvas = CE.defines("canvas_id").
|
|
351
|
-
extend(Scrolling).
|
|
352
|
-
ready(function() {
|
|
353
|
-
canvas.Scene.call("MyScene");
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
canvas.Scene.new({
|
|
357
|
-
name: "MyScene",
|
|
358
|
-
ready: function(stage) {
|
|
359
|
-
this.scrolling = canvas.Scrolling.new(this, 32, 32);
|
|
360
|
-
|
|
361
|
-
var player = this.createElement();
|
|
362
|
-
this.scrolling.setMainElement(player);
|
|
363
|
-
|
|
364
|
-
var map = this.createElement();
|
|
365
|
-
this.scrolling.addScroll({
|
|
366
|
-
element: map,
|
|
367
|
-
speed: 3,
|
|
368
|
-
block: true,
|
|
369
|
-
width: 120,
|
|
370
|
-
height: 50
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
render: function(stage) {
|
|
374
|
-
this.scrolling.update();
|
|
375
|
-
stage.refresh();
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
*/
|
|
380
|
-
var Scrolling = {
|
|
381
|
-
Scrolling: {
|
|
382
|
-
New: function() { return this["new"].apply(this, arguments); },
|
|
383
|
-
"new": function(scene, tile_h, tile_w) {
|
|
384
|
-
return Class["new"]("Scrolling", [scene, tile_h, tile_w]);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|