Browse Source

Updating CharacterAnimation2D

Josh Engebretson 10 years ago
parent
commit
8a408a72d2
32 changed files with 271 additions and 85 deletions
  1. 1 0
      CharacterAnimation2D/.gitignore
  2. 5 0
      CharacterAnimation2D/Resources.asset
  3. 5 0
      CharacterAnimation2D/Resources/Components.asset
  4. 22 12
      CharacterAnimation2D/Resources/Components/Imp.js
  5. 7 0
      CharacterAnimation2D/Resources/Components/Imp.js.asset
  6. 29 51
      CharacterAnimation2D/Resources/Components/UI.js
  7. 7 0
      CharacterAnimation2D/Resources/Components/UI.js.asset
  8. 5 0
      CharacterAnimation2D/Resources/Scenes.asset
  9. 75 0
      CharacterAnimation2D/Resources/Scenes/Scene.scene
  10. 5 0
      CharacterAnimation2D/Resources/Scenes/Scene.scene.asset
  11. 5 0
      CharacterAnimation2D/Resources/Scripts.asset
  12. 4 22
      CharacterAnimation2D/Resources/Scripts/main.js
  13. 7 0
      CharacterAnimation2D/Resources/Scripts/main.js.asset
  14. 5 0
      CharacterAnimation2D/Resources/Skin.asset
  15. 14 0
      CharacterAnimation2D/Resources/Skin/skin.ui.txt
  16. BIN
      CharacterAnimation2D/Resources/Skin/spaceship.png
  17. 5 0
      CharacterAnimation2D/Resources/Skin/spaceship.png.asset
  18. BIN
      CharacterAnimation2D/Resources/Skin/window.png
  19. 5 0
      CharacterAnimation2D/Resources/Skin/window.png.asset
  20. 5 0
      CharacterAnimation2D/Resources/Sprites.asset
  21. 5 0
      CharacterAnimation2D/Resources/Sprites/imp.scml.asset
  22. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_all.png.asset
  23. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_blood.png.asset
  24. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_body.png.asset
  25. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_footbig.png.asset
  26. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_footsmall.png.asset
  27. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_handbig.png.asset
  28. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_handsmall.png.asset
  29. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_handthrow.png.asset
  30. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_head.png.asset
  31. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_headangry.png.asset
  32. 5 0
      CharacterAnimation2D/Resources/Sprites/imp_headblink.png.asset

+ 1 - 0
CharacterAnimation2D/.gitignore

@@ -0,0 +1 @@
+Cache/*

+ 5 - 0
CharacterAnimation2D/Resources.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "e179e5fbf5d4225c337438a2b5fd4dfb",
+	"FolderImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Components.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "7d4ca6511312175b7283fcb391355d07",
+	"FolderImporter": {}
+}

+ 22 - 12
CharacterAnimation2D/Resources/Components/Imp.js

@@ -1,19 +1,29 @@
+'atomic component';
 
+exports.component = function(self) {
 
-var game = Atomic.game;
-var node = self.node;
+    var node = self.node;
 
-var animationSet = game.cache.getResource("AnimationSet2D", "Sprites/imp.scml");
-var sprite2D = node.createComponent("AnimatedSprite2D");
+    var animatedSprite = node.getComponent("AnimatedSprite2D");
 
-self.playAnimation = function(animation) {
+    self.subscribeToEvent("PlayRun", function() {
+        animatedSprite.setAnimation("run");
+    });
 
-    sprite2D.setAnimation(animationSet, animation, Atomic.LM_FORCE_LOOPED);
-}
+    self.subscribeToEvent("PlayIdle", function() {
+        animatedSprite.setAnimation("idle");
+    });
 
-function start() {
-	
-	sprite2D.setAnimation(animationSet, "idle");
-	
-}
+    self.subscribeToEvent("PlayAttack", function() {
+        animatedSprite.setAnimation("attack");
+    });
 
+    self.subscribeToEvent("PlayHit", function() {
+        animatedSprite.setAnimation("hit");
+    });
+
+    self.subscribeToEvent("PlayDead", function() {
+        animatedSprite.setAnimation("dead");
+    });
+
+}

+ 7 - 0
CharacterAnimation2D/Resources/Components/Imp.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "f70bb90a07b40b0d0bd839d94cfadc3c",
+	"JavascriptImporter": {
+		"IsComponentFile": true
+	}
+}

+ 29 - 51
CharacterAnimation2D/Resources/Components/UI.js

@@ -1,70 +1,48 @@
-// Atomic Component
+'atomic component';
 
-var game = Atomic.game;
-var node = self.node;
+var fd = new Atomic.UIFontDescription();
+fd.id = "Vera";
+fd.size = 22;
 
-var ui = game.ui;
-var root = ui.getRoot();
+function createButton(self, text, event, layout) {
 
-var font = game.cache.getResource("Font", "Fonts/Anonymous Pro.ttf");
+    var button = new Atomic.UIButton();
+    button.text = text;
+    button.fontDescription = fd;
 
-var uiStyle = game.cache.getResource("XMLFile", "UI/DefaultStyle.xml");
-root.defaultStyle = uiStyle;
+    button.gravity = Atomic.UI_GRAVITY_RIGHT;
 
-var container = new Atomic.UIElement();
-container.horizontalAlignment = Atomic.HA_RIGHT;
-container.verticalAlignment = Atomic.VA_CENTER;
-container.layoutMode = Atomic.LM_VERTICAL;
+    button.onClick = function() {
 
-root.addChild(container);
+        self.sendEvent(event);
 
-var buttons = {};
+    }
 
-function addButton(name, text, callback) {
+    layout.addChild(button);
 
-    var button = new Atomic.Button();
-    
-    button.setName(name);
-    button.setMinWidth(120);
-    button.setMinHeight(24);
-
-    var buttonText = new Atomic.Text();
-    buttonText.text = text;
-    buttonText.setFont(font, 12);
-    buttonText.color = [0, 1, 0, 1];
-
-    buttonText.horizontalAlignment = Atomic.HA_CENTER;
-    buttonText.verticalAlignment = Atomic.VA_CENTER;
-    button.addChild(buttonText); 
-    container.addChild(button);
-    button.setStyleAuto();   
-    
-    buttons[name] = callback;       
-   
 }
 
-addButton("PlayIdle", "Idle", function() { TheImp.playAnimation("idle"); }); 
-addButton("PlayRun", "Run", function() { TheImp.playAnimation("run"); }); 
-addButton("PlayAttack", "Attack", function() { TheImp.playAnimation("attack"); });
-addButton("PlayHit", "Hit", function() { TheImp.playAnimation("hit"); });
-addButton("PlayDead", "Dead", function() { TheImp.playAnimation("dead"); }); 
+exports.component = function(self) {
 
-self.onMouseClick = function(element) {
+    // TODO: fixme
+    Atomic.UI.__init();
 
-    var name = element.name;
-    
-    buttons[name]();
-    
-}
+    // root view
+    self.uiView = new Atomic.UIView();
 
-function start() {
+    var layout = new Atomic.UILayout();
+    layout.rect = self.uiView.rect;
 
-    self.listenToEvent(null, "UIMouseClick", self.onMouseClick );
-}
+    layout.axis = Atomic.UI_AXIS_Y;
 
-function update(timeStep) {
+    layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_GRAVITY;
 
-    
+    self.uiView.addChild(layout);
 
-}
+    createButton(self, "Play Idle", "PlayIdle", layout);
+    createButton(self, "Play Run", "PlayRun", layout);
+    createButton(self, "Play Attack", "PlayAttack", layout);
+    createButton(self, "Play Hit", "PlayHit", layout);
+    createButton(self, "Play Dead", "PlayDead", layout);
 
+}

+ 7 - 0
CharacterAnimation2D/Resources/Components/UI.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "ec48129375b082a5b5bf57a354b2bc09",
+	"JavascriptImporter": {
+		"IsComponentFile": true
+	}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Scenes.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "98b68eb6b3adf268218189b03ba8a78d",
+	"FolderImporter": {}
+}

+ 75 - 0
CharacterAnimation2D/Resources/Scenes/Scene.scene

@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="365" />
+	<attribute name="Next Replicated Component ID" value="1980" />
+	<attribute name="Next Local Node ID" value="16778503" />
+	<attribute name="Next Local Component ID" value="16777222" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<component type="Renderer2D" id="1978" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+	</node>
+	<node id="363">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="AnimatedCharacter" />
+		<attribute name="Position" value="-0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="JSComponent" id="1975">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/UI.js" />
+		</component>
+		<component type="JSComponent" id="1976">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/Imp.js" />
+		</component>
+		<component type="AnimatedSprite2D" id="1977">
+			<attribute name="Animation Set" value="AnimationSet2D;Sprites/imp.scml" />
+			<attribute name="Animation" value="idle" />
+		</component>
+	</node>
+</scene>

+ 5 - 0
CharacterAnimation2D/Resources/Scenes/Scene.scene.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c256eab3f0621de21f574aaa6e9275ba",
+	"SceneImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Scripts.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "f296d93a9975a139c62f102a9e555089",
+	"FolderImporter": {}
+}

+ 4 - 22
CharacterAnimation2D/Resources/Scripts/main.js

@@ -1,29 +1,11 @@
 // This script is the main entry point of the game
-require("AtomicGame");
 
-Atomic.game.init(start, update);
-
-
-// called at the start of play
-function start() {
-
-    var game = Atomic.game;
-
-    // create a 2D scene
-    game.createScene2D();
-
-    // create the game component
-    var node = game.scene.createChild("Imp");
-    TheImp = node.createJSComponent("Imp");
+var scene = Atomic.player.loadScene("Scenes/Scene.scene");
 
+// called per frame, optional
+function update(timeStep) {
 
-    var uiNode = game.scene.createChild("UI");
-    uiNode.createJSComponent("UI");
 
 }
 
-// called per frame
-function update(timeStep) {
-
-
-}
+exports.update = update;

+ 7 - 0
CharacterAnimation2D/Resources/Scripts/main.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "f0195740019586a7e1969368917f5c63",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Skin.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "899ba421d6d37345ba96f1045f8dd653",
+	"FolderImporter": {}
+}

+ 14 - 0
CharacterAnimation2D/Resources/Skin/skin.ui.txt

@@ -0,0 +1,14 @@
+elements
+	Spaceship
+		bitmap spaceship.png
+		pref-width 32
+		pref-height 32
+	SpaceGameContainer
+		type StretchBox
+		bitmap window.png
+		cut 16
+		expand 12
+		padding 8
+	SpaceText
+		text-color #00FF00
+

BIN
CharacterAnimation2D/Resources/Skin/spaceship.png


+ 5 - 0
CharacterAnimation2D/Resources/Skin/spaceship.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "fa084793c8f7c85ea355b64a531c7622",
+	"TextureImporter": {}
+}

BIN
CharacterAnimation2D/Resources/Skin/window.png


+ 5 - 0
CharacterAnimation2D/Resources/Skin/window.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "e2b0aed0e278aaa85124b142801c510a",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "8d3a8818e394406202706dc599761e79",
+	"FolderImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp.scml.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "e360f1a9f593f9d01ab548ee1f1464a6",
+	"SpriterImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_all.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "6c41c7c3fe44dffc90b0a570c641c194",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_blood.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "757436b4a755871dbc1cfa071c5c0042",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_body.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "fb2d59e2b8e0ce780283f5b0f854c3ea",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_footbig.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "e26b31a9bf13a6fe479193962974ff6e",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_footsmall.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "15339b03b8acc81af72921202f3590ed",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_handbig.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "3299a52e81a383a25dac2074cd73b147",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_handsmall.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "2070c7d25615fa8fe3c933cce1fcca2c",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_handthrow.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "4874e214d496d05f94e1004a5a10b1ed",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_head.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "85e99f47810f0b0c050c97035774fc94",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_headangry.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "25c00b445c323aa1f2c29ae8914e844f",
+	"TextureImporter": {}
+}

+ 5 - 0
CharacterAnimation2D/Resources/Sprites/imp_headblink.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "799e2afba1667456acb6e700e5dfe97f",
+	"TextureImporter": {}
+}