Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

place character correctly

  • Loading branch information...
commit 355f196c917f8511057717a93b1aa6694255531c 1 parent 872fab9
@rafd rafd authored
Showing with 28 additions and 22 deletions.
  1. +28 −22 index.html
View
50 index.html
@@ -34,19 +34,29 @@
window.document.addEventListener('touchmove', preventDefaultScroll, false);
- makeCharacter = function(director){
- var height_choices = ["s","t"];
- var weight_choices = ["s","f"];
- var color_choices = ["blue","purple","red"];
- var item_choices = ["glasses","hat","scarf"]; // TODO: null option
- var mood_choices = ["angry","happy","sad"];
+ var Game = {}
+
+ Game.Character = function(director){
+ var meta = {
+ height_choices: ["s","t"],
+ weight_choices: ["s","f"],
+ color_choices: ["blue","purple","red"],
+ item_choices: ["glasses","hat","scarf"], // TODO: null option
+ mood_choices: ["angry","happy","sad"],
+ dimensions: {
+ ss: [231,239],
+ sf: [231,239],
+ ts: [300,462],
+ tf: [300,462]
+ }
+ }
var c = {
- height: height_choices.randomElement(),
- weight: weight_choices.randomElement(),
- color: color_choices.randomElement(),
- item: item_choices.randomElement(),
- mood: mood_choices.randomElement(),
+ height: meta.height_choices.randomElement(),
+ weight: meta.weight_choices.randomElement(),
+ color: meta.color_choices.randomElement(),
+ item: meta.item_choices.randomElement(),
+ mood: meta.mood_choices.randomElement(),
images: {
face: new Image(),
body: new Image(),
@@ -54,8 +64,6 @@
}
}
- console.log(c.height+c.weight+c.color+c.mood)
-
var path = "assets/persons/";
var ext = ".png";
@@ -64,24 +72,22 @@
c.images.item.src = path + c.height + c.weight + "-" + c.item + ext;
var cActor = new CAAT.ActorContainer().
- setBounds(0,0,300,462).
- setFillStyle('#123456')
+ setBounds(0,0,300,462);
setTimeout(function(){ // HACK: timeout so that images have a chance to load
+ var x = 300, y = 462;
+
var face = new CAAT.Actor().
setBackgroundImage(c.images.face, true).
- setLocation(0, 0).
- setSize(60, 60);
+ setLocation((x-c.images.body.width)/2, (y-c.images.body.height));
var body = new CAAT.Actor().
setBackgroundImage(c.images.body, true).
- setLocation(0, 0).
- setSize(60, 60);
+ setLocation((x-c.images.body.width)/2, (y-c.images.body.height));
var item = new CAAT.Actor().
setBackgroundImage(c.images.item, true).
- setLocation(0, 0).
- setSize(60, 60);
+ setLocation((x-c.images.body.width)/2, (y-c.images.body.height));
cActor.addChild(body);
cActor.addChild(face);
@@ -106,7 +112,7 @@
scene.addChild(bg);
- var character = makeCharacter();
+ var character = new Game.Character();
bg.addChild(character);
Please sign in to comment.
Something went wrong with that request. Please try again.