Skip to content

Commit a3ea102

Browse files
authored
Merge branch 'master' into dev
2 parents d09a2a0 + 743e051 commit a3ea102

File tree

7 files changed

+79
-56
lines changed

7 files changed

+79
-56
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Nano TypeScript
22

33

4-
[![CircleCI](https://circleci.com/gh/PluginIO/nano-typescript.svg?style=svg)](https://circleci.com/gh/PluginIO/nano-typescript)
4+
[![CircleCI](https://circleci.com/gh/pluginio/nano-typescript.svg?style=svg)](https://circleci.com/gh/pluginio/nano-typescript)
55

66
## About
77

@@ -65,7 +65,7 @@ To run a development build, we simply run the following instruction in the **ter
6565

6666
`npm run dev`
6767

68-
You can now navigate to `http:/127.0.0.1:3000` in your browser. All being well you should see a sample of the **Nano** engine running in your browser. You can make changes to the source code and your changes will be reflected automatically upon saving.
68+
You can now navigate to `http://127.0.0.1:3000` in your browser. All being well you should see a sample of the **Nano** engine running in your browser. You can make changes to the source code and your changes will be reflected automatically upon saving.
6969

7070
### Release Build
7171

@@ -88,4 +88,4 @@ Also included is a suite of unit tests. Unit tests allow for the automation of t
8888
`npm run test`
8989

9090
## Many Thanks
91-
**Thank you** for checking out **Nano TypeScript**. We are super excited to see the amazing HTML5 games and apps that you build and we hope to showcase them here. Please let us know about your projects.
91+
**Thank you** for checking out **Nano TypeScript**. We are super excited to see the amazing HTML5 games and apps that you build and we hope to showcase them here. Please let us know about your projects. :)

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nano-typescript",
3-
"version": "0.0.3",
3+
"version": "0.0.5",
44
"description": "Super fast and lightweight 2D graphics library for TypeScript",
55
"scripts": {
66
"dev": "webpack serve --config webpack.dev.js --host 0.0.0.0 --port 3000 --content-base dev --inline --hot --mode development",
@@ -22,6 +22,9 @@
2222
],
2323
"author": "Gary Paluk",
2424
"license": "MIT",
25+
"publishConfig": {
26+
"registry": "https://registry.npmjs.org"
27+
},
2528
"bugs": {
2629
"url": "https://github.com/pluginio/nano-typescript/issues"
2730
},
@@ -56,4 +59,4 @@
5659
"remove-strict-webpack-plugin": "^0.1.2",
5760
"uglify-js": "^3.5.13"
5861
}
59-
}
62+
}

Diff for: src/Demo/View/GameScene.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import {Scene} from 'App/Scene'
2-
import {Assets} from 'Demo/Assets'
3-
import {TileSet} from 'Display/Tiles/TileSet'
4-
import {TileAnimation} from 'Display/Tiles/TileAnimation'
5-
import {TileMap} from 'Display/Tiles/TileMap'
6-
import {Sprite} from 'Display/Sprite'
7-
import {BlendMode} from 'Display/BlendMode'
8-
import {AnchorType} from 'Display/AnchorType'
9-
import {Color} from 'Display/Color'
10-
import {MovieClip} from 'Display/MovieClip'
11-
import {Tweener} from 'Animation/Tweener'
12-
import {EaseType} from 'Animation/EaseType'
13-
import {AudioMixer} from 'Audio/AudioMixer'
1+
import { Scene } from 'App/Scene'
2+
import { Assets } from 'Demo/Assets'
3+
import { TileSet } from 'Display/Tiles/TileSet'
4+
import { TileAnimation } from 'Display/Tiles/TileAnimation'
5+
import { TileMap } from 'Display/Tiles/TileMap'
6+
import { Sprite } from 'Display/Sprite'
7+
import { BlendMode } from 'Display/BlendMode'
8+
import { AnchorType } from 'Display/AnchorType'
9+
import { Color } from 'Display/Color'
10+
import { MovieClip } from 'Display/MovieClip'
11+
import { Tweener } from 'Animation/Tweener'
12+
import { EaseType } from 'Animation/EaseType'
13+
import { AudioMixer } from 'Audio/AudioMixer'
1414

1515
export class GameScene extends Scene {
16-
protected onAssetsError(e: Event): void {}
16+
protected onAssetsError(e: Event): void { }
1717

1818
public init(): void {
1919
this.assets.add(Assets.BUNNY_PATH)
@@ -50,7 +50,7 @@ export class GameScene extends Scene {
5050
let bunny: Sprite = this.assets.getSprite(Assets.BUNNY_PATH)
5151
bunny.blendMode = BlendMode.SOURCE_OVER
5252
bunny.anchorType = AnchorType.CENTER
53-
bunny.scale = 2
53+
bunny.scale = 0.5
5454
bunny.smoothing = false
5555
bunny.graphics.fillStyle = '#FF0000'
5656
bunny.graphics.fillRect(0, 0, 10, 10)

Diff for: src/Demo/View/SplashScene.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Scene} from 'App/Scene'
2-
import {Assets} from 'Demo/Assets'
3-
import {EventType} from 'Events/EventType'
4-
import {Button} from 'GUI/Button'
5-
import {AudioMixer} from 'Audio/AudioMixer'
6-
import {Sprite} from 'Display/Sprite'
7-
import {Color} from 'Display/Color'
8-
import {GameScene} from './GameScene'
1+
import { Scene } from 'App/Scene'
2+
import { Assets } from 'Demo/Assets'
3+
import { EventType } from 'Events/EventType'
4+
import { Button } from 'GUI/Button'
5+
import { AudioMixer } from 'Audio/AudioMixer'
6+
import { Sprite } from 'Display/Sprite'
7+
import { Color } from 'Display/Color'
8+
import { GameScene } from './GameScene'
99

1010
export class SplashScene extends Scene {
1111
public init(): void {

Diff for: src/Display/Container.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Spatial} from './Spatial'
1+
import { Spatial } from './Spatial'
22

33
export class Container extends Spatial {
44
protected _children: Spatial[]
@@ -32,6 +32,7 @@ export class Container extends Spatial {
3232
let index = this._children.lastIndexOf(spatial)
3333
if (index != -1) {
3434
spatial.parent = null
35+
spatial.dispose()
3536
this._children.splice(index, 1)
3637
}
3738
}

Diff for: src/Display/Sprite.ts

+32-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {BlendMode} from './BlendMode'
2-
import {Point} from 'Geom/Point'
3-
import {Container} from './Container'
4-
import {Matrix} from 'Geom/Matrix'
5-
import {Stage} from './Stage'
6-
import {Color} from './Color'
7-
import {AnchorType} from './AnchorType'
8-
import {Texture} from './Texture'
9-
import {Bound} from './Bound'
10-
import {Rectangle} from 'Geom/Rectangle'
1+
import { BlendMode } from './BlendMode'
2+
import { Point } from 'Geom/Point'
3+
import { Container } from './Container'
4+
import { Matrix } from 'Geom/Matrix'
5+
import { Stage } from './Stage'
6+
import { Color } from './Color'
7+
import { AnchorType } from './AnchorType'
8+
import { Texture } from './Texture'
9+
import { Bound } from './Bound'
10+
import { Rectangle } from 'Geom/Rectangle'
1111

1212
export class Sprite extends Container {
1313
public alpha: number = 1
@@ -56,9 +56,9 @@ export class Sprite extends Container {
5656
this.texture = texture
5757
} else {
5858
let img: HTMLImageElement = document.createElement('img')
59-
img.width = 300
60-
img.height = 200
61-
this._texture = new Texture(img)
59+
img.width = 10
60+
img.height = 10
61+
this.texture = new Texture(img)
6262
}
6363

6464
this._mask = document.createElement('img')
@@ -81,12 +81,23 @@ export class Sprite extends Container {
8181
public set texture(value: Texture) {
8282
//TODO [GJP] Tidy all this up
8383
this._texture = value
84-
this._targetCanvas.width = value.width
85-
this.canvas.width = value.width
86-
this._targetCanvas.height = value.height
87-
this.canvas.height = value.height
88-
this._width = value.width
89-
this._height = value.height
84+
85+
this.resizeWidth(value.width)
86+
this.resizeHeight(value.height)
87+
}
88+
89+
private resizeWidth(width: number): void {
90+
this._targetCanvas.width = width
91+
this.canvas.width = width
92+
this._width = width
93+
94+
this._isDirty = true
95+
}
96+
97+
private resizeHeight(height: number): void {
98+
this._targetCanvas.height = height
99+
this.canvas.height = height
100+
this._height = height
90101

91102
this._isDirty = true
92103
}
@@ -223,6 +234,7 @@ export class Sprite extends Container {
223234
}
224235

225236
public set width(value: number) {
237+
this.resizeWidth(value)
226238
this.scaleX = value / this._targetCanvas.width
227239
}
228240

@@ -231,6 +243,7 @@ export class Sprite extends Container {
231243
}
232244

233245
public set height(value: number) {
246+
this.resizeHeight(value)
234247
this.scaleY = value / this._targetCanvas.height
235248
}
236249

Diff for: src/Loaders/AssetLoader.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {EventDispatcher} from 'Events/EventDispatcher'
2-
import {EventType} from 'Events/EventType'
3-
import {Texture} from 'Display/Texture'
4-
import {Sprite} from 'Display/Sprite'
5-
import {TileSet} from 'Display/Tiles/TileSet'
6-
import {AudioClip} from 'Audio/AudioClip'
1+
import { EventDispatcher } from 'Events/EventDispatcher'
2+
import { EventType } from 'Events/EventType'
3+
import { Texture } from 'Display/Texture'
4+
import { Sprite } from 'Display/Sprite'
5+
import { TileSet } from 'Display/Tiles/TileSet'
6+
import { AudioClip } from 'Audio/AudioClip'
77

88
export class AssetLoader extends EventDispatcher {
99
public constructor() {
@@ -111,11 +111,14 @@ export class AssetLoader extends EventDispatcher {
111111
mimeType = this.getFileExtension(path)
112112
}
113113

114+
console.log("Asset loaded: " + path)
115+
console.log("MIME: " + mimeType)
116+
114117
switch (mimeType) {
115118
case 'png':
116119
case 'image/png':
117120
let png = document.createElement('img')
118-
png.src = path
121+
png.src = 'data:image/png;base64,' + btoa(String.fromCharCode.apply(null, data));
119122
png.crossOrigin = 'anonymous'
120123
png.height =
121124
(data[20] << 24) |
@@ -128,12 +131,15 @@ export class AssetLoader extends EventDispatcher {
128131
(data[18] << 8) |
129132
data[19]
130133
this._imageMap.set(path, png)
134+
135+
console.log("width: " + png.width + ", height: " + png.height)
136+
console.log("MIME: " + mimeType)
131137
break
132138
case 'jpg':
133139
case 'jpeg':
134140
case 'image/jpeg':
135141
let jpg = document.createElement('img')
136-
jpg.src = path
142+
jpg.src = 'data:image/png;base64,' + btoa(String.fromCharCode.apply(null, data));
137143
jpg.crossOrigin = 'anonymous'
138144

139145
let offset: number = 0

0 commit comments

Comments
 (0)