commit:695e5b0740f3dfa383b71102fe79738b113bed0b
author:Chip Black
committer:Chip Black
date:Sun Sep 11 23:30:55 2011 -0500
parents:2bea61647fe9b5071e1a488c2aa943703e35f852
Add prefs for Landscape
diff --git a/hacks/Landscape/Landscape.js b/hacks/Landscape/Landscape.js
line changes: +14/-3
index 5d6fb74..3c0262e
--- a/hacks/Landscape/Landscape.js
+++ b/hacks/Landscape/Landscape.js
@@ -4,6 +4,15 @@ enyo.kind({
 	name: "Landscape",
 	kind: "Hack",
 	style: "background-color: #2ab40f",
+	preferences: [
+		{name: "direction", label: "Direction of Travel", kind: "ListSelector", items: [
+			{caption: "right", value: -1},
+			{caption: "left", value: 1}
+		]},
+		{name: "speed", label: "Speed", kind: "Slider", minimum: 0.1, maximum: 10, snap: 0.1}
+	],
+	direction: -1,
+	speed: 1.0,
 	components: [
 		{name: "clouds", style: "height: 200px; background-image: url(hacks/Landscape/clouds.png)"},
 		{name: "mountains", style: "height: 200px; background-image: url(hacks/Landscape/mountains.png)"},
@@ -22,9 +31,11 @@ enyo.kind({
 		this.timer = null;
 	},
 	draw: function() {
-		this.n--;
-		if (this.n == -1600)
-		       this.n = 0;
+		this.n += this.direction * this.speed;
+		if (this.n <= -1600)
+			this.n += 1600;
+		else if (this.n >= 1600)
+			this.n -= 1600;
 
 		this.$.clouds.applyStyle("background-position", (this.n * 1.5) + "px top");
 		this.$.mountains.applyStyle("background-position", (this.n * 2.5) + "px top");