Permalink
Browse files

add constructors to WindowStyle and SpriteSet

  • Loading branch information...
Anatoli Steinmark
Anatoli Steinmark committed Dec 13, 2011
1 parent bd0ced6 commit f5cf83036053808ffca844a12e0d4c9e6145b381
Showing with 23 additions and 19 deletions.
  1. +1 −0 common/scripts/font.nut
  2. +13 −12 common/scripts/spriteset.nut
  3. +9 −7 common/scripts/windowstyle.nut
View
@@ -1,5 +1,6 @@
// ---------------------------------------------------
class Font {
+
constructor(images_) {
images = images_;
maxHeight = 0;
@@ -1,5 +1,17 @@
// ---------------------------------------------------
class SpriteSet {
+
+ constructor(frame_width, frame_height, base_x1, base_y1, base_x2, base_y2, images_, directions_) {
+ frameWidth = frame_width;
+ frameHeight = frame_height;
+ baseX1 = base_x1;
+ baseY1 = base_y1;
+ baseX2 = base_x2;
+ baseY2 = base_y2;
+ images = images_;
+ directions = directions_;
+ }
+
frameWidth = null;
frameHeight = null;
baseX1 = null;
@@ -92,16 +104,5 @@ function SpriteSet::Load(filename) {
}
- // create spriteset
- local ss = Spriteset();
- ss.frameWidth = frame_width;
- ss.frameHeight = frame_height;
- ss.baseX1 = base_x1;
- ss.baseY1 = base_y1;
- ss.baseX2 = base_x2;
- ss.baseY2 = base_y2;
- ss.images = images;
- ss.directions = directions;
-
- return ss;
+ return Spriteset(frame_width, frame_height, base_x1, base_y1, base_x2, base_y2, images, directions);
}
@@ -1,5 +1,13 @@
// ---------------------------------------------------
class WindowStyle {
+
+ constructor(background_mode, corner_colors, edge_offsets, images_) {
+ backgroundMode = background_mode;
+ cornerColors = corner_colors;
+ edgeOffsets = edge_offsets;
+ images = images_;
+ }
+
backgroundMode = null; // 0 = tiled, 1 = stretched, 2 = gradient (uses corner colors), 3 = tiled with gradient, 4 = stretched with gradient
cornerColors = null; // upper left, upper right, lower left, lower right
edgeOffsets = null; // left, top, right, bottom
@@ -59,13 +67,7 @@ function WindowStyle::Load(filename) {
images[i] = Texture(image);
}
- local ws = WindowStyle();
- ws.backgroundMode = background_mode;
- ws.cornerColors = corner_colors;
- ws.edgeOffsets = edge_offsets;
- ws.images = images;
-
- return ws;
+ return WindowStyle(background_mode, corner_colors, edge_offsets, images);
}
// ---------------------------------------------------

0 comments on commit f5cf830

Please sign in to comment.