Skip to content

Commit

Permalink
add #75
Browse files Browse the repository at this point in the history
  • Loading branch information
izure committed May 13, 2021
1 parent 470d895 commit 5474fb0
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 84 deletions.
8 changes: 4 additions & 4 deletions src/Template/Game/ACTOR.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Phaser from 'phaser'
import BaseScene from '@/BaseScene'
import BaseActor from '@/BaseActor'

{{ DATA_LISTS }}
Expand All @@ -25,7 +26,7 @@ import BaseActor from '@/BaseActor'

export default class SampleActor extends BaseActor {

constructor(scene: Phaser.Scene, x: number, y: number, texture: string|Phaser.Textures.Texture, frame?: string|number) {
constructor(scene: BaseScene, x: number, y: number, texture: string|Phaser.Textures.Texture, frame?: string|number) {
super(scene, x, y, texture, frame)
this.generateScript(Storages, '{{ STORAGE_KEY }}')
}
Expand All @@ -41,8 +42,7 @@ export default class SampleActor extends BaseActor {
super.update(time, delta)
// 이 아래에 작성하세요

// this.playMovingAnimation()
// this.run.stop()
this.playMovingAnimation()
}

end(): void {
Expand All @@ -54,7 +54,7 @@ export default class SampleActor extends BaseActor {
protected playMovingAnimation(): void {

if (!this.run.isMoving) {
this.play(Animations[].key, true)
// this.play(Animations[].key, true)
}
if (this.run.isMovingLeft) {
// this.flipX = false
Expand Down
38 changes: 37 additions & 1 deletion src/Template/Game/BASE_SCENE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class BaseScene extends Phaser.Scene {
if (!callbacks) {
return
}
callbacks.forEach((callback): void => callback.call(this, args))
callbacks.forEach((callback): void => callback.call(this, ...args))
}

private loadImage(): void {
Expand Down Expand Up @@ -338,9 +338,45 @@ export default class BaseScene extends Phaser.Scene {
this.loadAssets()
}

private usePointerEvent(): void {
this.input.on(Phaser.Input.Events.POINTER_DOWN, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerDown'), e)
})
this.input.on(Phaser.Input.Events.POINTER_DOWN_OUTSIDE, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerDown'), e)
})
this.input.on(Phaser.Input.Events.POINTER_UP, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerUp'), e)
})
this.input.on(Phaser.Input.Events.POINTER_UP_OUTSIDE, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerUp'), e)
})
this.input.on(Phaser.Input.Events.POINTER_MOVE, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerMove'), e)
})
this.input.on(Phaser.Input.Events.POINTER_WHEEL, (e: Phaser.Input.Pointer): void => {
this.runScript(this.__scripts.get('onPointerWheel'), e)
})
}

private useKeyboardEvent(): void {
this.input.keyboard.on(Phaser.Input.Keyboard.Events.ANY_KEY_DOWN, (e: KeyboardEvent): void => {
this.runScript(this.__scripts.get('onKeyDown'), e)
})
this.input.keyboard.on(Phaser.Input.Keyboard.Events.ANY_KEY_UP, (e: KeyboardEvent): void => {
this.runScript(this.__scripts.get('onKeyUp'), e)
})
}

create(): void {
this.createAnimation()
this.createMap()
this.usePointerEvent()
this.useKeyboardEvent()

// 마우스 우클릭으로 나오는 컨텍스트 메뉴를 비활성화합니다.
this.input.mouse.disableContextMenu()

this.runScript(this.__scripts.get('onSceneCreate'))
}

Expand Down
93 changes: 93 additions & 0 deletions src/Template/Game/SCENE_SCRIPT.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Phaser from 'phaser'
import * as Key from 'keycode-js'
import { Actor } from '@eriengine/plugin-actor'

{{ DATA_LISTS }}
Expand Down Expand Up @@ -66,4 +67,96 @@ export function onSceneUpdate(this: Scene, time: number, delta: number): void {
*/
export function onSceneDestroy(this: Scene): void {
{{ onSceneDestroy }}
}



// ██████╗ ██████╗ ██╗███╗ ██╗████████╗███████╗██████╗ ███████╗██╗ ██╗███████╗███╗ ██╗████████╗
// ██╔══██╗██╔═══██╗██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗ ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝
// ██████╔╝██║ ██║██║██╔██╗ ██║ ██║ █████╗ ██████╔╝ █████╗ ██║ ██║█████╗ ██╔██╗ ██║ ██║
// ██╔═══╝ ██║ ██║██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗ ██╔══╝ ╚██╗ ██╔╝██╔══╝ ██║╚██╗██║ ██║
// ██║ ╚██████╔╝██║██║ ╚████║ ██║ ███████╗██║ ██║ ███████╗ ╚████╔╝ ███████╗██║ ╚████║ ██║
// ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝
//
// 여기서부터 씬의 포인터 이벤트입니다.
// 포인터를 눌렀거나, 땠을 때 등을 처리할 수 있습니다.

/**
* 포인터를 눌렀을 때 호출될 함수입니다.
* 이 함수는 포인터를 누른 순간만 작동합니다.
* @param e 포인터 이벤트 정보입니다.
*/
export function onPointerDown(this: Scene, e: Phaser.Input.Pointer): void {
{{ onPointerDown }}
}

/**
* 포인터를 땠을 때 호출될 함수입니다.
* 이 함수는 포인터를 땐 순간만 작동합니다.
* @param e 포인터 이벤트 정보입니다.
*/
export function onPointerUp(this: Scene, e: Phaser.Input.Pointer): void {
{{ onPointerUp }}
}

/**
* 포인터를 움직일 때 호출될 함수입니다.
* @param e 포인터 이벤트 정보입니다.
*/
export function onPointerMove(this: Scene, e: Phaser.Input.Pointer): void {
{{ onPointerMove }}
}

/**
* 씬에서 포인터의 휠을 굴렸을 때 호출될 함수입니다.
* @param events 포인터 이벤트 정보입니다.
*/
export function onPointerWheel(this: Scene, e: Phaser.Input.Pointer): void {
{{ onPointerWheel }}
}



// ██╗ ██╗███████╗██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██████╗ ███████╗██╗ ██╗███████╗███╗ ██╗████████╗
// ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔══██╗██╔═══██╗██╔══██╗██╔══██╗██╔══██╗ ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝
// █████╔╝ █████╗ ╚████╔╝ ██████╔╝██║ ██║███████║██████╔╝██║ ██║ █████╗ ██║ ██║█████╗ ██╔██╗ ██║ ██║
// ██╔═██╗ ██╔══╝ ╚██╔╝ ██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██║ ██╔══╝ ╚██╗ ██╔╝██╔══╝ ██║╚██╗██║ ██║
// ██║ ██╗███████╗ ██║ ██████╔╝╚██████╔╝██║ ██║██║ ██║██████╔╝ ███████╗ ╚████╔╝ ███████╗██║ ╚████║ ██║
// ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝
//
// 여기서부터 씬의 키보드 이벤트입니다.
// 키보드의 키를 눌렀거나, 땠을 때 등을 처리할 수 있습니다.

/**
* 키보드를 눌렀을 때 호출될 함수입니다.
* 이 함수는 키를 누른 순간만 작동합니다.
* 특정 키를 감지하고 싶다면, `e.code`를 사용하여 특정 키의 코드값을 얻어오십시오.
* @param e 키보드 이벤트 정보입니다.
*/
export function onKeyDown(this: Scene, e: KeyboardEvent): void {
switch (e.code) {
// case Key.CODE_F: {
// break
// }
// case Key.CODE_ENTER: {
// break
// }
}
}

/**
* 키보드를 땠을 때 호출될 함수입니다.
* 이 함수는 키를 땐 순간만 작동합니다.
* 특정 키를 감지하고 싶다면, `e.code`를 사용하여 특정 키의 코드값을 얻어오십시오.
* @param e 키보드 이벤트 정보입니다.
*/
export function onKeyUp(this: Scene, e: KeyboardEvent): void {
switch (e.code) {
// case Key.CODE_F: {
// break
// }
// case Key.CODE_ENTER: {
// break
// }
}
}
38 changes: 19 additions & 19 deletions src/Template/Project/Build-App/MAIN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ const { app, BrowserWindow } = require('electron')
const mode = '{{ BUILD_MODE }}'

function createWindow () {
const win = new BrowserWindow({
width: {{ WIDTH }},
height: {{ HEIGHT }},
webPreferences: {
spellcheck: false,
nodeIntegration: true
}
})

if (mode === 'prod') {
win.setMenu(null)
const win = new BrowserWindow({
width: {{ WIDTH }},
height: {{ HEIGHT }},
webPreferences: {
spellcheck: false,
nodeIntegration: true
}
win.setResizable({{ RESIZABLE }})
win.loadFile('{{ INDEX }}')
})

if (mode === 'prod') {
win.setMenu(null)
}
win.setResizable({{ RESIZABLE }})
win.loadFile('{{ INDEX }}')
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
52 changes: 26 additions & 26 deletions src/Template/Project/Build-App/PACKAGE.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"main": "main.js",
"build": {
"appId": "{{ applicationId }}",
"productName": "{{ name }}",
"win": {
"target": [{
"target": "nsis",
"arch": [ "x64", "ia32" ]
}],
"icon": "../../src/Build/favicon.png"
},
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true,
"language": 1042,
"shortcutName": "{{ name }}"
},
"directories": {
"output": "{{ OUTPUT }}"
}
"main": "main.js",
"build": {
"appId": "{{ applicationId }}",
"productName": "{{ name }}",
"win": {
"target": [{
"target": "nsis",
"arch": [ "x64", "ia32" ]
}],
"icon": "../../src/Build/favicon.png"
},
"devDependencies": {
"electron": "^11.2.0",
"electron-builder": "^22.9.1"
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true,
"language": 1042,
"shortcutName": "{{ name }}"
},
"scripts": {
"electron:build": "npx electron-builder"
"directories": {
"output": "{{ OUTPUT }}"
}
},
"devDependencies": {
"electron": "^11.2.0",
"electron-builder": "^22.9.1"
},
"scripts": {
"electron:build": "npx electron-builder"
}
}
38 changes: 19 additions & 19 deletions src/Template/Project/Build-Web/HTML.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>{{ TITLE }}</title>
<meta charset="utf-8">
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
}
</style>
<script type="text/javascript" src="./js/main.js"></script>
</head>
<body>
<div id="canvas-wrapper"></div>
</body>
<head>
<title>{{ TITLE }}</title>
<meta charset="utf-8">
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
}
</style>
<script type="text/javascript" src="./js/main.js"></script>
</head>
<body>
<div id="canvas-wrapper"></div>
</body>
</html>
28 changes: 14 additions & 14 deletions src/Template/Project/Extend/PACKAGE.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"applicationId": "{{ applicationId }}",
"name": "{{ name }}",
"version": "{{ version }}",
"description": "{{ description }}",
"author": "{{ author }}",
"license": "{{ license }}",
"engineAuth": "{{ engineAuth }}",
"engineVersion": "{{ engineVersion }}",
"gameDisplaySize": [{{ gameDisplaySize }}],
"gameDisplayResizable": {{ gameDisplayResizable }},
"gameThemeTextColor": "{{ gameThemeTextColor }}",
"gameThemeBackgroundColor": "{{ gameThemeBackgroundColor }}",
"dependencies": {},
"devDependencies": {}
"applicationId": "{{ applicationId }}",
"name": "{{ name }}",
"version": "{{ version }}",
"description": "{{ description }}",
"author": "{{ author }}",
"license": "{{ license }}",
"engineAuth": "{{ engineAuth }}",
"engineVersion": "{{ engineVersion }}",
"gameDisplaySize": [{{ gameDisplaySize }}],
"gameDisplayResizable": {{ gameDisplayResizable }},
"gameThemeTextColor": "{{ gameThemeTextColor }}",
"gameThemeBackgroundColor": "{{ gameThemeBackgroundColor }}",
"dependencies": {},
"devDependencies": {}
}
3 changes: 2 additions & 1 deletion src/Template/Project/PACKAGE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"webpack-dev-server": "^3.11.2",
"@webpack-cli/serve": "^1.2.2",
"fast-glob": "^3.2.5",
"copy-webpack-plugin": "^7.0.0"
"copy-webpack-plugin": "^7.0.0",
"keycode-js": "^3.1.0"
}
}

0 comments on commit 5474fb0

Please sign in to comment.