entryjs๋ ์ํธ๋ฆฌ ๊ต์ก์ฐ๊ตฌ์์์ ๊ฐ๋ฐํ HTML5 ๊ธฐ๋ฐ์ ๋ธ๋ก์ฝ๋ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ๋๋ค. ์ํธ๋ฆฌ ์ฌ์ดํธ์ ์ ์ํ์๋ฉด entryjs๋ฅผ ์ฌ์ฉํ ๋ธ๋ก์ฝ๋ฉ ํ๊ฒฝ์ ํ์ธํด ๋ณผ ์ ์์ต๋๋ค.
entryjs๋ HTML Canvas์ ์ค๋์ค, ๋ฒกํฐ ์ด๋ฏธ์ง๋ฑ์ ๋ค๋ฃจ๊ธฐ ์ํด ๋ช๊ฐ์ง ์คํ์์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ์ฌ์ฉํฉ๋๋ค. ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ด ์นํ๋ก์ ํธ์ ๋จผ์ ๋ก๋ฉ๋ ํ์ entryjs๋ฅผ ๋ก๋ฉํ์ฌ์ผ ํฉ๋๋ค.
- jQuery - 1.9.1
- jquery-ui - 1.10.4
- Underscore - 1.8.3
- CreateJS
- EaselJS - 0.8.0
- PreloadJS - 0.6.0
- SoundJS - 0.6.0
- Web Font Loader - 1.5.2
์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ๋ชจ๋ ์คํ์์ค๋ก ๋ฐฐํฌ๋๋ฉฐ, ์ง์ ๋ค์ด๋ก๋ ๋ฐ๊ฑฐ๋ npm, bower๋ฑ์ ์ด์ฉํด ์ค์นํ ์ ์์ต๋๋ค.
<!-- ์จ๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค -->
<script type='text/javascript' src='${LIBDIR}/jquery.js'>
<script type='text/javascript' src='${LIBDIR}/underscore.js'>
<script type='text/javascript' src='${LIBDIR}/PreloadJS/lib/preloadjs-0.6.0.min.js'>
<script type='text/javascript' src='${LIBDIR}/EaselJS/lib/easeljs-0.8.0.min.js'>
<script type='text/javascript' src='${LIBDIR}/SoundJS/lib/soundjs-0.6.0.min.js'>
<script type='text/javascript' src='${LIBDIR}/SoundJS/lib/flashaudioplugin-0.6.0.min.js'>
<script type='text/javascript' src="${LIBDIR}/webfont/1.5.18/webfont.js"></script>
<!-- entryjs ๋ฐ entryjs ์ ํฌํจ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค -->
<script type='text/javascript' src='${LIBDIR}/entryjs/extern/blockly/blockly_compressed.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/static.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/context.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/CanvasInput.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/handle.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/ndgmr.Collision.js'>
<script type='text/javascript' src='${LIBDIR}/entryjs/util/ko.js'>
<!-- entryjs core -->
<script type='text/javascript' src='${LIBDIR}/entryjs/dist/entry.min.js'>๋ธ๋ก ๋์์ธ๊ณผ ๊ด๋ จ๋ ๊ธฐ๋ณธ์ ์ธ ์คํ์ผ๋ค์ด ์ ์๋์ด ์์ต๋๋ค.
<link rel='stylesheet' href='${LIBDIR}/entryjs/dist/entry.css'>ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ entryjs๋ฅผ ๋ก๋ฉํ์์ผ๋ฉด ํ์ฌ DOM์ ํน์ ์์น์ Javascript๋ฅผ ์ด์ฉํด entryjs workspace๋ฅผ ์ฃผ์ ํ ์ ์์ต๋๋ค.
-
Entry.init(domElement, initOptions);
<div id="workspace"></div>
var workspace = document.getElementById("workspace"); var initOptions = { type: 'workspace', libDir: '/lib', fonts: [{ name: '๋๋๊ณ ๋', family: 'Nanum Gothic', url: '/css/nanumgothic.css' }] }; Entry.init(workspace, initOptions);
-
domElement : Entry๊ฐ Inject๋ DOM ๋ ธ๋.
-
initOptions : entryjs workspace์ ์ต์ ๊ฐ.
Workspace ํ์ ๊ณผ ํฐํธ์ ๋ณด๋ฅผ ์ ์ธํ ๋ชจ๋ ์ต์ ์ ์ ํ์ฌํญ์ด๋ฉฐ Boolean ํ์ ์ ๋๋ค.
-
ํ์ํญ๋ชฉ
- type: ์ํฌ์คํ์ด์ค ํ์ . (workspace: ๋ง๋ค๊ธฐ ํ๊ฒฝ, minimize: ๊ตฌ๊ฒฝํ๊ธฐ ํ๊ฒฝ)
- libDir: ์จ๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ฅ์. entryjs๋ฅผ ํฌํจํ Library ์์น. (๊ธฐ๋ณธ๊ฐ: '/lib')
- fonts: ์นํฐํธ ์ ๋ณด
-
์ ํํญ๋ชฉ
- projectsaveable: ํ๋ก์ ํธ ์ ์ฅ๊ฐ๋ฅ ์ฌ๋ถ (true)
- objectaddable: ์ค๋ธ์ ํธ ์ถ๊ฐ๊ฐ๋ฅ ์ฌ๋ถ (true)
- objectEditable: ์ค๋ธ์ ํธ ์์ ๊ฐ๋ฅ ์ฌ๋ถ (true). ์ด๊ฐ์ false๋ก ์ธํ ํ๋ฉด objectAddable๋ false๊ฐ ๋๋ค.
- objectdeletable: ์ค๋ธ์ ํธ ์ญ์ ๊ฐ๋ฅ ์ฌ๋ถ (true)
- soundeditable: ์๋ฆฌ ์์ ๊ฐ๋ฅ ์ฌ๋ถ (true)
- pictureeditable: ๋ชจ์ ์์ ๊ฐ๋ฅ ์ฌ๋ถ (true)
- sceneEditable: ์ฅ๋ฉด ์์ ๊ฐ๋ฅ ์ฌ๋ถ (true)
- functionEnable: ํจ์ ์ฌ์ฉ๊ฐ๋ฅ ์ฌ๋ถ (true)
- messageEnable: ์ ํธ ์ฌ์ฉ๊ฐ๋ฅ ์ฌ๋ถ (true)
- variableEnable: ๋ณ์ ์ฌ์ฉ๊ฐ๋ฅ ์ฌ๋ถ (true)
- listEnable: ๋ฆฌ์คํธ ์ฌ์ฉ๊ฐ๋ฅ ์ฌ๋ถ (true)
- isForLecture: ๊ฐ์์ฉ ํ๋ก์ ํธ ์ฌ๋ถ (false)
-
์นํฐํธ ์ ๋ณด ์ํธ๋ฆฌ ๊ธ์์์ ๊ทธ๋ฆผํ์์ ์ฌ์ฉํ ํฐํธ๋ค์ ํ๋ ์ด์ ๋ฐฐ์ด๋ก ์ถ๊ฐํ ์ ์์ต๋๋ค.
[{ name: 'ํ๋ฉด์ ํ์ํ ํฐํธ ์ด๋ฆ', family: 'font-family ์ด๋ฆ', url: 'ํฐํธ ์ ์ํ์ผ ๊ฒฝ๋ก' }]
// ์์ [{ name: '๋๋๊ณ ๋', family: 'Nanum Gothic', url: '/css/nanumgothic.css' }, { name: '๋๋ํ๊ธฐ์ฒด', family: 'Nanum Pen Script', url: '/css/nanumpenscript.css' }]
๋ฌด๋ฃ ํ๊ธ ์นํฐํธ๋ https://www.google.com/fonts/earlyaccess ์์ ๋ค์ด๋ก๋ ํ์ค ์ ์์ต๋๋ค.
๋ธ๋ก๋ฉ๋ด ์ด๊ธฐํ
์๋์ด๋ ธ ์ด๊ธฐํ, Web socket connection ์คํ
ํ๋ก์ ํธ ๋ถ๋ฌ์ค๊ธฐ. project ์ธ์๋ฅผ ์๋ตํ ๊ฒฝ์ฐ ๊ธฐ๋ณธ ํ๋ก์ ํธ๋ฅผ ๋ฆฌํดํฉ๋๋ค.
- event listening
Entry.addEventListener(eventName, function);- eventName: ์บ์นํ๊ณ ์ถ์ ์ปค์คํ ์ด๋ฒคํธ์ ์ด๋ฆ
- function: ํด๋น ์ปค์คํ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๊ฒฝ์ฐ ์คํ ๋ ํจ์
- event dispatch
Entry.dispatchEvent(eventName,params);- eventName: ๋ฐ์ ์ํค๊ณ ์ถ์ ์ด๋ฒคํธ์ ์ด๋ฆ
- params: ์ด๋ฒคํธ๋ฅผ ๋ฆฌ์ค๋ ํ๊ณ ์๋ ์ฝ๋ฐฑํจ์์ ๋๊ฒจ์ค ํ๋ผ๋ฏธํฐ
- ๋ํ์ ์ธ ์ด๋ฒคํธ
- run
- stop
- ์ ์ ์ธํฐ๋์
- keyPressed
- keyUpped
- canvasClick
- canvasClickCanceled
- entityClick
- entityClickCanceled
- stageMouseMove
- stageMouseOut
- ํ๋ฉด
- windowResized
- ์ํฌ์คํ์ด์ค ํ๋จ์ ์๋ฆผ ๋ฉ์์ง ํ์
- Entry.Toast.warning(title, message, auto-dospose); // ์ฃผ์
- Entry.Toast.success(title, message, auto-dospose); // ์ฑ๊ณต
- Entry.Toast.alert(title, message, auto-dospose); // ๊ฒฝ๊ณ
${entryjs}/src/blocks.js
Blockly.Blocks.move_x = {
init: function() {
this.setColour("#A751E3");
this.appendDummyInput()
.appendField(Lang.Blocks.MOVING_move_x_1);
this.appendValueInput("VALUE")
.setCheck(["Number", "String"]);
this.appendDummyInput()
.appendField(Lang.Blocks.MOVING_move_x_2)
.appendField(new Blockly.FieldIcon('/img/assets/block_icon/moving_03.png', '*'));
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};Entry.block.move_x = function (sprite, script) {
var value = script.getNumberValue("VALUE", script);
sprite.setX(sprite.getX() + value);
if (sprite.brush && !sprite.brush.stop) {
sprite.brush.lineTo(sprite.getX(), sprite.getY()*-1);
}
return script.callReturn();
};
```
### ํ๋ก์ ํธ (Project Schema)
### ์ ์ฅ
: ์๋์ Entry ํจ์๋ฅผ ์ด์ฉํด ํ์์ ๋ณด๋ค์ JSONํํ๋ก ์ ์ฅํ ์ ์์ต๋๋ค.
์ ์ฅ๋ ํ๋ก์ ํธ๋ Entry.loadProject(project) ๋ฅผ ์ด์ฉํด ๋ค์ ๋ก๋ํ ์ ์์ต๋๋ค.
```javascript
var project = Entry.exportProject();
```
### ์์ธ ์คํค๋ง
```javascript
/**
* MongoDB ์คํค๋ง ์์ .
*/
var ProjectSchema = new Schema({
speed: { // ์ด๋น ์คํ ํ๋ ์์
type: Number,
default: 60
},
objects: [ // ์ค๋ธ์ ํธ ๋ชฉ๋ก
{
id: String, // ์ค๋ธ์ ํธ ID. Unique.
name: String, // ์ค๋ธ์ ํธ(๋๋ ๊ธ์์ ์ ๋ชฉ) ์ด๋ฆ.
text: String, // ๊ธ์์ ๋ด์ฉ. (objectType์ด textBox์ผ ๊ฒฝ์ฐ)
order: Number, // TODO
objectType: String, // ์ค๋ธ์ ํธ ์ ํ. (sprite, textBox)
scene: String, // ์ฅ๋ฉด ID. Unique.
active: { // ์ค๋ธ์ ํธ ํ์ฑํ ์ฌ๋ถ
type: Boolean,
default: true
},
lock: { // ์ค๋ธ์ ํธ ์ ๊ธ ์ฌ๋ถ
type: Boolean,
default: false
},
rotateMethod: String, // ํ์ ๋ฐฉ์. (free, vertical, none)
entity: { // ์ํฐํฐ ์ ๋ณด
rotation: Number, // ํ์
direction: Number, // ๋ฐฉํฅ
x: Number, // x ์ขํ
y: Number, // y ์ขํ
regX: Number, // ๊ฐ๋ก ์ค์ฌ์
regY: Number, // ์ธ๋ก ์ค์ฌ์
scaleX: Number, // ๊ฐ๋ก ๋ฐฐ์จ
scaleY: Number, // ์ธ๋ก ๋ฐฐ์จ
width: Number, // ๋์ด
height: Number, // ๋์ด
imageIndex: Number, // TODO
visible: Boolean, // ํ๋ฉดํ์ ์ฌ๋ถ
colour: String, // ๊ธ์์ ํฐํธ์๊น
font: String, // ๊ธ์์ ํฐํธ
bgColor: String, // ๊ธ์์ ๋ฐฐ๊ฒฝ์๊น
textAlign: Number, // ๊ธ์์ ์ ๋ ฌ
lineBreak: Boolean, // ๊ธ์์ ์ค๋ฐ๊ฟ ์ฌ๋ถ
underLine: Boolean, // ๊ธ์์
strike: Boolean // ๊ธ์์ ๋ฐ์ค
},
script: String, // ๋ธ๋ก ์คํฌ๋ฆฝํธ
sprite: { // ์คํ๋ผ์ดํธ ์ ๋ณด
name: String, // ์คํ๋ผ์ดํธ ์ด๋ฆ
pictures: [{ // ๋ชจ์ ๋ชฉ๋ก
id: String, // ๋ชจ์ ID. Unique/
name: String, // ๋ชจ์ ์ด๋ฆ
fileurl: String, // ๋ชจ์ ์ด๋ฏธ์ง
dimension: { // ๋ชจ์ ํฌ๊ธฐ
width: Number,
height: Number,
scaleX: Number,
scaleY: Number
},
scale: { // ํ๋, ์ถ์ ๋น์จ(100% ๊ธฐ์ค)
type: Number,
default: 100
}
}],
sounds: [{ // ์๋ฆฌ ๋ชฉ๋ก
id: String, // ์๋ฆฌ ID. Unique.
name: String, // ์ด๋ฆ
fileurl: String, // ์ฌ์ด๋ ํ์ผ URL
duration: Number // ์ฌ์์๊ฐ. (์ด๋จ์)
}]
},
selectedPictureId: String, // ํ์ฌ ํ์ฑํ๋ ๋ชจ์์ ID
selectedSoundId: String // ํ์ฌ ํ์ฑํ๋ ์๋ฆฌ์ ID
}
],
variables: [ // ํ๋ก์ ํธ ๋ณ์
{
name: String, // ๋ณ์๋ช
variableType: String, // ๋ณ์ํ. (์ผ๋ฐ๋ณ์: variable, ํ์ด๋จธ: timer, ๋๋ต: answer, ์ฌ๋ผ์ด๋: slide, ๋ฆฌ์คํธ: list)
id: String, // ๋ณ์ID. Unique.
value: String, // ๋ณ์ ๊ฐ
minValue: Number, // ์ต์๊ฐ
maxValue: Number, // ์ต๋๊ฐ
visible: Boolean, // ์บ๋ฒ์ค์ ํ์์ฌ๋ถ
x: Number, // ์ปจ๋ฒ์ค ์์น x์ขํ
y: Number, // ์บ๋ฒ์ค ์์น y์ขํ
width: Number, // ๋์ด
height: Number, // ๋์ด
isCloud: { // ๊ณต์ ๋ณ์ ์ฌ๋ถ
type: Boolean,
default: false
},
object: { // ์ง์ญ๋ณ์์ผ ๊ฒฝ์ฐ ์ฐธ์กฐํ๋ ์ค๋ธ์ ํธ ID
type: String,
default: null
},
array: [{ // ๋ณ์ํ์ด list์ผ ๊ฒฝ์ฐ ๊ฐ ๋ชฉ๋ก
data: String // ๊ฐ ๋ฐ์ดํฐ
}]
}
],
messages: [ // ์ ํธ ๋ชฉ๋ก
{
name: String, // ์ ํธ๋ช
id: String // ์ ํธ ID. Unique.
}
],
functions: [ // ํจ์ ๋ชฉ๋ก
{
id: String, // ํจ์ ID. Unique.
block: String, // ํจ์ ๋ธ๋ก ์ ๋ณด
content: String, // ํจ์ ์คํ ์ ๋ณด
id: String,
name: String
}]
}
],
scenes: { // ์ฅ๋ฉด ์ ๋ณด
type: [ // ์ฅ๋ฉด ๋ชฉ๋ก
{
name: String, // ์ฅ๋ฉด ์ด๋ฆ
id: String // ์ฅ๋ฉด ID. Unique.
}
]
},
});
```
### Sprite, Picture, Sound schema
### ์คํ๋ผ์ดํธ
```javascript
var SpriteSchema = new Schema({
name: String, // ์คํ๋ผ์ดํธ ์ด๋ฆ
pictures: [{ // ๋ชจ์ ๋ชฉ๋ก
name: String, // ๋ชจ์ ์ด๋ฆ
fileurl: String, // ๋ชจ์ ์ด๋ฏธ์ง
dimension: { // ๋ชจ์ ํฌ๊ธฐ
width: Number,
height: Number
}
}],
sounds: [{ // ์๋ฆฌ ๋ชฉ๋ก
name: String, // ์ด๋ฆ
fileurl: String, // ์ฌ์ด๋ ํ์ผ URL
duration: Number // ์ฌ์์๊ฐ. (์ด๋จ์)
}]
})
```
#### ๋ชจ์
```javascript
var PictureSchema = new Schema({
name: String, // ๋ชจ์ ์ด๋ฆ
fileurl: String, // ๋ชจ์ ์ด๋ฏธ์ง
dimension: { // ๋ชจ์ ํฌ๊ธฐ
width: Number,
height: Number
}
})
```
#### ์๋ฆฌ
```javascript
var SoundSchema = new Schema({
name: String, // ์ด๋ฆ
fileurl: String, // ์ฌ์ด๋ ํ์ผ URL
duration: Number // ์ฌ์์๊ฐ. (์ด๋จ์)
})
```
## Copyright and License
EntryJS Copyright (c) 2015 Entry Labs.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.