Skip to content

Commit 3a17260

Browse files
author
ajie
committed
update v2.2.1
update v2.2.1
1 parent e6840ea commit 3a17260

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1326
-695
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,33 @@ Check out examples at http://a-jie.github.io/Proton/
1818
- Integratable into any game engine
1919
- Veriety of behaviors
2020
- Three kinds of emitters which can simulate many different physical effects
21-
- The 3d version of the proton engine is here https://a-jie.github.io/three.proton/
21+
- The __3D version__ of the proton engine is here [https://a-jie.github.io/three.proton/](https://a-jie.github.io/three.proton/)
2222

2323
## Usage
2424
```javascript
2525
var proton = new Proton();
2626
var emitter = new Proton.Emitter();
27+
2728
//set Rate
2829
emitter.rate = new Proton.Rate(Proton.getSpan(10, 20), 0.1);
30+
2931
//add Initialize
3032
emitter.addInitialize(new Proton.Radius(1, 12));
3133
emitter.addInitialize(new Proton.Life(2, 4));
3234
emitter.addInitialize(new Proton.Velocity(3, Proton.getSpan(0, 360), 'polar'));
35+
3336
//add Behaviour
3437
emitter.addBehaviour(new Proton.Color('ff0000', 'random'));
3538
emitter.addBehaviour(new Proton.Alpha(1, 0));
39+
3640
//set emitter position
3741
emitter.p.x = canvas.width / 2;
3842
emitter.p.y = canvas.height / 2;
3943
emitter.emit();
44+
4045
//add emitter to the proton
4146
proton.addEmitter(emitter);
47+
4248
// add canvas renderer
4349
var renderer = new Proton.Renderer('canvas', proton, canvas);
4450
renderer.start();
@@ -48,12 +54,24 @@ Proton.USE_CLOCK = false or true;
4854
```
4955

5056
## Building Proton
51-
Node is a dependency, use terminal to install it with with:<br>
52-
`git clone git://github.com/a-jie/Proton.git`<br>
53-
Then navigate to the build directory by running:<br>
54-
`cd ./build`<br>
55-
Finally run the build command:<br>
56-
`node build.js`
57+
Node is a dependency, use terminal to install it with with:
58+
`git clone git://github.com/a-jie/Proton.git`
59+
60+
Then navigate to the build directory by running:
61+
62+
```
63+
cd ./build
64+
node build.js
65+
```
66+
67+
Or use npm script
68+
```
69+
npm run build
70+
```
71+
72+
## Changelog
73+
Detailed changes for each release are documented in the [release notes](https://github.com/a-jie/Proton/releases).
74+
5775

5876
## License
5977
Proton is released under the MIT License. http://www.opensource.org/licenses/mit-license

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "Proton",
3-
"version": "2.1.0",
3+
"version": "2.2.1",
44
"homepage": "http://a-jie.github.io/Proton",
55
"authors": [
66
"a-jie <a-jie.cn@msn.com>"
77
],
88
"description": "Proton is an easily customizable html5 particle engine including five different types of renderers.",
9-
"main": "build/proton-2.1.0.min.js",
9+
"main": "build/proton.min.js",
1010
"license": "MIT",
1111
"ignore": [
1212
"**/.*",

build/build.js

Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,71 @@
11
var fs = require("fs"),
2-
uglify = {
3-
parser: require("./lib/parse-js.js"),
4-
processor: require("./lib/process.js")
5-
},
6-
7-
// Set the config filename
8-
configfile = "config",
9-
10-
config, version, source_dir, output_full, output_min, head, filenames, foot, i,
11-
ast, minified_source,
12-
13-
files = [],
14-
numFiles = 0,
15-
16-
source = "";
2+
uglify = {
3+
parser: require("./lib/parse-js.js"),
4+
processor: require("./lib/process.js")
5+
},
6+
7+
// Set the config filename
8+
configfile = "config",
9+
10+
config, version, source_dir, output_full, output_min, head, umd, filenames, foot, i,
11+
ast, minified_source,
12+
13+
files = [],
14+
numFiles = 0,
15+
16+
source = "";
1717

1818
// Get config file
1919
console.log("Reading config file...");
2020
config = fs.readFileSync(configfile, "UTF-8");
2121

2222
// Get variables from config file
2323
version = /^version = (.*)$/m.exec(config)[1],
24-
source_dir = /^source_dir = (.*)$/m.exec(config)[1],
25-
output_full = /^output_full = (.*)$/m.exec(config)[1].replace("{version}", version),
26-
output_min = /^output_min = (.*)$/m.exec(config)[1].replace("{version}", version),
27-
head = /head\s-----\s([\s\S]*?)-----\s/g.exec(config)[1].replace("{version}", version).replace("{year}", "2011-" + (new Date()).getFullYear()),
28-
filenames = /files\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
29-
foot = /foot\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
24+
source_dir = /^source_dir = (.*)$/m.exec(config)[1],
25+
output_full = /^output_full = (.*)$/m.exec(config)[1].replace("{version}", version),
26+
output_min = /^output_min = (.*)$/m.exec(config)[1].replace("{version}", version),
27+
head = /head\s-----\s([\s\S]*?)-----\s/g.exec(config)[1].replace("{version}", version).replace("{year}", "2011-" + (new Date()).getFullYear()),
28+
umd = /umd\s-----\s([\s\S]*?)-----\s/g.exec(config)[1],
29+
filenames = /files\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
30+
3031
numFiles = filenames.length;
31-
filenames = filenames.concat(foot);
3232

3333
// Get all the source files
3434
for (i = 0; i < filenames.length; i++) {
35-
console.log("Reading file: " + filenames[i]);
36-
37-
// Add current file
38-
files.push({
39-
name: filenames[i],
40-
content: fs.readFileSync(source_dir + filenames[i], "UTF-8")
41-
});
35+
console.log("Reading file: " + filenames[i]);
36+
37+
// Add current file
38+
files.push({
39+
name: filenames[i],
40+
content: fs.readFileSync(source_dir + filenames[i], "UTF-8")
41+
});
4242
}
43-
43+
4444
// Start the building process
4545
console.log("Building source file...");
4646

47-
// Add the head code to the top of the file
48-
source = head;
49-
50-
// Loop through all files and append the source
47+
source = head + umd;
5148
for (i = 0; i < numFiles; i++) {
5249

53-
// Replace the self executing anonymous functions that wrap each file
54-
// Only the end of core will be removed, and added to the end of the new file
55-
if (files[i].name === "core/Proton.js") {
56-
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\(window(\s|)\);/, "");
57-
} else {
58-
files[i].content = files[i].content.replace(/\(function(\s|)\((\s|)Proton,(\s|)undefined(\s|)\)(\s|)\{/, "");
59-
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\((\s|)Proton(\s|)\);/, "");
60-
}
61-
62-
// Append the file to the full source
63-
source += "\n" + files[i].content;
64-
65-
// Append the end of the core wrapper
66-
if (i === numFiles - 1) {
67-
source += "\n})(window);";
68-
}
69-
}
50+
if (files[i].name === "core/Proton.js") {
51+
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\(window(\s|)\);/, "");
52+
files[i].content = files[i].content.replace(/\(function\(window\,\sundefined\)\s\{/, "");
53+
files[i].content = files[i].content.replace(/window\.Proton\s\=\sProton\;/, "");
54+
} else {
55+
files[i].content = files[i].content.replace(/\(function(\s|)\((\s|)Proton,(\s|)undefined(\s|)\)(\s|)\{/, "");
56+
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\((\s|)Proton(\s|)\);/, "");
57+
}
7058

71-
// Loop through all foot files
72-
for (i = numFiles; i < numFiles + foot.length; i++) {
59+
// Append the file to the full source
60+
source += "\n" + files[i].content;
7361

74-
// Append the file to the full source
75-
source += "\n" + files[i].content;
62+
// Append the end of the core wrapper
63+
if (i === numFiles - 1) {
64+
//source += "\n})(window);";
65+
source += "\n\n return Proton;\n}));";
66+
}
7667
}
77-
68+
///console.log(umd);
7869
// Save source to output file
7970
fs.writeFile(output_full, source, "UTF-8");
8071
console.log("Source file saved as: " + output_full);
@@ -89,4 +80,4 @@ minified_source = uglify.processor.gen_code(ast);
8980

9081
// Save minified source file
9182
fs.writeFile(output_min, head + minified_source, "UTF-8");
92-
console.log("Minified source file saved as: " + output_min);
83+
console.log("Minified source file saved as: " + output_min);

build/config

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
version = 2.1.0
1+
version = 2.2.1
22
source_dir = ../src/
3-
output_full = proton-{version}.js
4-
output_min = proton-{version}.min.js
3+
output_full = proton.js
4+
output_min = proton.min.js
55

66
head
77
-----
@@ -16,6 +16,19 @@ head
1616
*/
1717
-----
1818

19+
umd
20+
-----
21+
(function (root, factory) {
22+
if (typeof define === 'function' && define.amd) {
23+
define([], factory);
24+
} else if (typeof module !== 'undefined' && module.exports) {
25+
module.exports = factory();
26+
} else {
27+
root.Proton = factory();
28+
}
29+
}(this, function () {
30+
-----
31+
1932
files
2033
-----
2134
core/Proton.js
@@ -73,11 +86,6 @@ zone/CircleZone.js
7386
zone/PointZone.js
7487
zone/RectZone.js
7588
zone/ImageZone.js
76-
debug/log.js
7789
debug/Debug.js
78-
-----
79-
80-
foot
81-
-----
8290
plus/requestAnimationFrame.js
8391
-----

build/proton-2.1.0.min.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)