-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
105 lines (94 loc) · 2.35 KB
/
gulpfile.js
File metadata and controls
105 lines (94 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var gulp = require('gulp');
var concat = require('gulp-concat');
var spritesmith = require('gulp.spritesmith');
var PROJECT_NAME = "game-template";
gulp.task('spritesheet-json', function() {
// generate PNG and JSON files for game images
return gulp.src("./app/game/sprites/*.*")
.pipe(spritesmith({
imgName: PROJECT_NAME + ".png",
cssName: PROJECT_NAME + ".json",
cssTemplate: texturePackerTemplate,
algorithm: "binary-tree",
padding: 1
}))
.pipe(gulp.dest("./dist/assets/"));
function texturePackerTemplate(params) {
var items = params.items,
itemObj = {frames: []},
frames = itemObj.frames,
item;
if (items.length > 0) {
item = items[0];
itemObj.meta = {
app: "https://github.com/Ensighten/spritesmith",
image: item.image,
format: "RGBA8888",
size: {
w: item.total_width,
h: item.total_height
},
scale: 1
};
}
items.forEach(function (item) {
frames.push({
filename: item.name,
frame: {
x: item.x,
y: item.y,
w: item.width,
h: item.height
},
rotated: false,
trimmed: false,
spriteSourceSize: {
x: 0,
y: 0,
w: item.width,
h: item.height
},
sourceSize: {
w: item.width,
h: item.height
}
});
});
return JSON.stringify(itemObj);
}
});
gulp.task('spritesheet-css', function() {
// generate PNG and CSS files for game images
return gulp.src("./app/game/sprites/*.*")
.pipe(spritesmith({
imgName: PROJECT_NAME + ".png",
cssName: PROJECT_NAME + ".css",
cssOpts: {
cssSelector: function(sprite) {
return '.' + sprite.name;
}
},
algorithm: "binary-tree",
padding: 1
}))
.pipe(gulp.dest("./dist/assets/"));
});
gulp.task('phaser', function() {
return gulp.src([
'node_modules/phaser/build/pixi.min.js',
'node_modules/phaser/build/phaser.min.js',
'node_modules/phaser-ads/build/phaser-ads.min.js'
])
.pipe(concat('phaser.js'))
.pipe(gulp.dest('./dist/assets'));
});
gulp.task('spritesheet', ['spritesheet-css', 'spritesheet-json'], function() {
});
gulp.task('fonts', function() {
return gulp.src([
'app/game/fonts/**/*'
])
.pipe(gulp.dest('./dist/assets/fonts'));
});
gulp.task('default', ['spritesheet', 'fonts', 'phaser'], function() {
});