Commit c7018134 authored by Cody Ede (cme527)'s avatar Cody Ede (cme527)
Browse files

Text is off set, stimulus is working.

parent a8cd0cdd
......@@ -30,7 +30,7 @@ fastTapMenu.position.x = 5;
fastTapMenu.position.y = 5;
var stimulus = new Stimulus();
stimulus.view.position.x = 1330;
stimulus.view.position.x = 1280;
stimulus.view.position.y = 355;
var instructions = new Instructions();
......
var PIXI = require('pixi.js'),
FastTapMenuItem = require('./FastTapMenuItem.js');
FastTapMenuItem = require('./StimulusMenuItem.js');
function Stimulus() {
this.view = new PIXI.Container();
......
var PIXI = require('pixi.js');
var int2clr = require('./int2clr.js');
var BG_COLOR = 0xc8c8c8;
var BG_COLOR_HOVER = 0xd6d6d6;
function FastTapMenuItem(name, iconPath, width, height) {
PIXI.Container.call(this);
this.name = name;
this.w = width;
this.h = height;
this.hovered = false;
this.label = new PIXI.Text(this.name, {font:"11pt Arial", fill:"#000000", align:"center"});
this.icon = new PIXI.Sprite( PIXI.Texture.fromImage(iconPath) );
this.bg = new PIXI.Graphics();
this.addChild(this.bg);
this.addChild(this.icon);
this.addChild(this.label);
this.interactive = true;
this.mouseover = function(data) {
this.hovered = true;
this.updateLayout();
};
this.mouseout = function(data) {
this.hovered = false;
this.updateLayout();
};
this.updateLayout();
}
FastTapMenuItem.constructor = FastTapMenuItem;
FastTapMenuItem.prototype = Object.create(PIXI.Container.prototype);
FastTapMenuItem.prototype.setItemAlpha = function(alpha) {
this.icon.alpha = alpha;
this.label.alpha = alpha;
};
FastTapMenuItem.prototype.updateLayout = function() {
this.label.position.x = Math.floor(this.w / 2 - this.label.width / 2);
this.label.position.y = Math.floor(this.h - (this.h / 5));
this.icon.anchor.x = 0.5;
this.icon.anchor.y = 0.5;
this.icon.width = this.w / 2;
this.icon.height = this.w / 2; // wont work with non-square icons
this.icon.position.x = this.w / 2;
this.icon.position.y = this.h / 2;
this.bg.clear();
if (this.hovered) {
this.bg.beginFill(BG_COLOR_HOVER);
} else {
this.bg.beginFill(BG_COLOR);
}
this.bg.drawRect(0,0,this.w,this.h);
};
module.exports = FastTapMenuItem;
......@@ -8,7 +8,7 @@ var PIXI = require('pixi.js'),
Experiment = require('./LearningExperiment.js');
var STAGE_BG = 0xffffff;
var WIDTH = 2440;
var WIDTH = 2880;
var HEIGHT = 1620;
var renderer = new PIXI.autoDetectRenderer(WIDTH, HEIGHT,{backgroundColor: STAGE_BG});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment