initGraphics: function() { this.pressedButtonTexture = Assets.Texture(Assets.Images.FIRE_BUTTON_PRESSED); this.unpressedButtonTexture = Assets.Texture(Assets.Images.FIRE_BUTTON_UNPRESSED); this.button = new PIXI.Sprite(this.unpressedButtonTexture); this.button.buttonMode = true; this.button.defaultCursor = 'pointer'; this.button.anchor.x = 0.5; this.button.anchor.y = 0.5; this.button.x = -104; this.button.scale.x = this.button.scale.y = 0.4; this.pivotPointOffset = new Vector2(-70, 0); this.dragHandle = new PIXI.Container(); this.dragHandle.hitArea = new PIXI.Rectangle(-42, -16, 42, 32); this.dragHandle.buttonMode = true; this.dragHandle.defaultCursor = 'row-resize'; if (!this.rotationEnabled) this.dragHandle.visible = false; this.gunSprite = Assets.createSprite(Assets.Images.NEUTRON_GUN); this.gunSprite.anchor.x = 1; this.gunSprite.anchor.y = (30 / 104); this.gunSprite.addChild(this.button); this.gunSprite.addChild(this.dragHandle); this.displayObject.addChild(this.gunSprite); this.updateMVT(this.mvt); },
initGraphics: function() { ObjectView.prototype.initGraphics.apply(this, arguments); // Put an extra transform frame inside the picture container this.pictureScaleFrame = new PIXI.Container(); while (this.pictureContainer.children.length > 0) { // Move the original contents of the picture container into // the transform frame that is going to go inside it. var child = this.pictureContainer.getChildAt(0); this.pictureContainer.removeChild(child); this.pictureScaleFrame.addChild(child); } this.pictureContainer.addChild(this.pictureScaleFrame); // Use reversed versions of the picture images this.pictureSprites[Types.PICTURE_A].texture = Assets.Texture(Assets.Images.PICTURE_A_REVERSED); this.pictureSprites[Types.PICTURE_B].texture = Assets.Texture(Assets.Images.PICTURE_B_REVERSED); this.pictureSprites[Types.PICTURE_C].texture = Assets.Texture(Assets.Images.PICTURE_C_REVERSED); this.pictureSprites[Types.PICTURE_D].texture = Assets.Texture(Assets.Images.PICTURE_D_REVERSED); // Change the anchors for the reversing effect for (var key in this.pictureSprites) { this.pictureSprites[key].anchor.x = 1 - this.pictureSprites[key].anchor.x; this.pictureSprites[key].anchor.y = 1 - this.pictureSprites[key].anchor.y; } this.updateStrength(this.model, this.model.get('strength')); },
initParticles: function() { /* * The particles will be added to the sprites layer, which is always * scaled with the images. In this way we shouldn't ever have to * reference the mvt object and do conversions when controlling * the behavior of our particles or move their transform origin. */ var particleContainer = new PIXI.Container(); this.spritesLayer.addChildAt(particleContainer, 0); var flameParticleTexture = Assets.Texture(Assets.Images.FLAME_PARTICLE); var smokeParticleTexture = Assets.Texture(Assets.Images.SMOKE_PARTICLE);//PIXI.Texture.generateRoundParticleTexture(0, 20, CannonView.SMOKE_PARTICLE_COLOR); this.activeFlameParticles = []; this.dormantFlameParticles = []; this.activeSmokeParticles = []; this.dormantSmokeParticles = []; var i; var particle; // Smoke particles for (i = 0; i < CannonView.NUM_SMOKE_PARTICLES; i++) { particle = new PIXI.Sprite(smokeParticleTexture); particle.visible = false; particle.anchor.x = particle.anchor.y = 0.5; particle.velocity = new Vector2(); particleContainer.addChild(particle); this.dormantSmokeParticles.push(particle); } // Flame particles (in front of smoke particles) for (i = 0; i < CannonView.NUM_FLAME_PARTICLES; i++) { particle = new PIXI.Sprite(flameParticleTexture); particle.visible = false; particle.anchor.x = particle.anchor.y = 0.5; particle.blendMode = PIXI.blendModes.ADD; // Get that good bright flame effect particle.velocity = new Vector2(); particleContainer.addChild(particle); this.dormantFlameParticles.push(particle); } // Range of a particle's starting y before rotation this.flameParticleStartYRange = range({ min: -CannonView.PARTICLE_EMISSION_AREA_WIDTH / 2 + CannonView.FLAME_PARTICLE_RADIUS_RANGE.min, max: CannonView.PARTICLE_EMISSION_AREA_WIDTH / 2 - CannonView.FLAME_PARTICLE_RADIUS_RANGE.min }); // End of cannon relative to origin minus the particle radius so it starts inside the bore this.flameParticleStartX = this.cannon.width * (1 - this.cannon.anchor.x) - CannonView.FLAME_PARTICLE_RADIUS_RANGE.min; },
updateMVT: function(mvt) { this.mvt = mvt; this.tileSize = this.mvt.modelToViewDeltaX(Constants.TILE_SIZE); this.tileScale = this.tileSize / Assets.Texture(Assets.Images.FLOOR).width; this.drawLevel(); },
initLabBenchSurface: function() { var labBenchSurfaceTexture = Assets.Texture(Assets.Images.SHELF_LONG); var labBenchSurface = new PIXI.Sprite(labBenchSurfaceTexture); labBenchSurface.anchor.y = 1; labBenchSurface.x = -(labBenchSurface.width - this.width) / 2; labBenchSurface.y = this.height; // labBenchSurface.x = this.mvt.modelToViewX(0) - labBenchSurfaceTexture.width / 2; // labBenchSurface.y = this.mvt.modelToViewY(0) - labBenchSurfaceTexture.height / 2 + 10; this.backLayer.addChild(labBenchSurface); },
initComponentGraphics: function() { this.texture = Assets.Texture(this.imagePath); this.schematicTexture = Assets.Texture(this.schematicImagePath); this.sprite = new PIXI.Sprite(this.texture); this.sprite.anchor.x = this.anchorX; this.sprite.anchor.y = this.anchorY; this.displayObject.addChild(this.sprite); this.displayObject.buttonMode = true; this.displayObject.defaultCursor = 'move'; this.flame = Assets.createMovieClip(Assets.Animations.FLAME); this.flame.anchor.x = 0.5; this.flame.anchor.y = 0.65; this.flame.x = this.sprite.width / 2; this.flame.animationSpeed = 0.25; this.flame.visible = false; this.effectsLayer.addChild(this.flame); },
initButton: function() { this.pressedButtonTexture = Assets.Texture(Assets.Images.FIRE_BUTTON_PRESSED); this.unpressedButtonTexture = Assets.Texture(Assets.Images.FIRE_BUTTON_UNPRESSED); var targetWidth = NuclearReactorView.BUTTON_WIDTH; var scale = targetWidth / this.pressedButtonTexture.width; var paddingLeft = 14; var paddingTop = 10; this.button = new PIXI.Sprite(this.unpressedButtonTexture); this.button.buttonMode = true; this.button.defaultCursor = 'pointer'; this.button.anchor.x = 0.5; this.button.anchor.y = 0.5; this.button.scale.x = this.button.scale.y = scale; this.button.x = paddingLeft + this.button.width / 2; this.button.y = paddingTop + this.button.height / 2; var label = new PIXI.Text('Fire Neutrons', { font: NuclearReactorView.BUTTON_LABEL_FONT, fill: NuclearReactorView.BUTTON_LABEL_COLOR }); label.x = NuclearReactorView.BUTTON_WIDTH + paddingLeft * 2; label.y = NuclearReactorView.BUTTON_PANEL_HEIGHT / 2; label.anchor.y = 0.5; label.resolution = this.getResolution(); this.buttonPanel = new PIXI.Graphics(); this.buttonPanel.addChild(this.button); this.buttonPanel.addChild(label); this.buttonPanel.lineStyle(NuclearReactorView.BUTTON_PANEL_BORDER_WIDTH, REACTOR_WALL_COLOR, 1); this.buttonPanel.beginFill(Colors.parseHex(NuclearReactorView.COOL_REACTOR_CHAMBER_COLOR), 1); this.buttonPanel.drawRect(0, 0, NuclearReactorView.BUTTON_PANEL_WIDTH, NuclearReactorView.BUTTON_PANEL_HEIGHT); this.buttonPanel.endFill(); this.displayObject.addChild(this.buttonPanel); },
initSpectrum: function() { // Get the spectrum image and draw it to a hidden canvas so we can // pull pixel data from it to determine the resistor's color. var spectrumTexture = Assets.Texture(Assets.Images.SPECTRUM); var spectrumImage = spectrumTexture.baseTexture.source; var canvas = document.createElement('canvas'); canvas.width = spectrumTexture.width; canvas.height = spectrumTexture.height; this.spectrumContext = canvas.getContext('2d'); this.spectrumContext.drawImage(spectrumImage, 0, 0, spectrumTexture.width, spectrumTexture.height); this.spectrumWidth = spectrumTexture.width; this.ratioSamples = new NumberSeries(ResistorView.NUM_RATIO_SAMPLES); this.numSame = 0; },
initGraphics: function() { var smokeParticleTexture = Assets.Texture(Assets.Images.SMOKE_PARTICLE); this.activeSmokeParticles = []; this.dormantSmokeParticles = []; var particle; // Smoke particles for (var i = 0; i < VolcanoSmokeView.NUM_PARTICLES; i++) { particle = new PIXI.Sprite(smokeParticleTexture); particle.visible = false; particle.anchor.x = particle.anchor.y = 0.5; particle.velocity = new Vector2(); this.displayObject.addChild(particle); this.dormantSmokeParticles.push(particle); } this.updateMVT(this.mvt); },
initialize: function(options) { // A map of wavelengths to colors for caching this.colors = {}; // Make all the photons brighter by putting a brightness // filter on the whole displayObject var colorMatrix = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; var filter = new PIXI.filters.ColorMatrixFilter(); filter.matrix = colorMatrix; filter.brightness(2.3, false); this.displayObject.filters = [filter]; // UV texture this.uvTexture = Assets.Texture(Assets.Images.PHOTON_UV); SpriteCollectionView.prototype.initialize.apply(this, arguments); },
initGraphics: function() { PixiSceneView.prototype.initGraphics.apply(this, arguments); var labBenchSurfaceTexture = Assets.Texture(Assets.Images.SHELF_LONG); var scale; if (AppView.windowIsShort()) scale = 1400; else scale = 2000; this.viewOriginX = Math.round(this.width / 2); this.viewOriginY = Math.round(this.height - labBenchSurfaceTexture.height * 0.64); //Math.round(this.height * 0.85);//my failed attempt at making it less magic and more data-based this.mvt = ModelViewTransform.createSinglePointScaleInvertedYMapping( new Vector2(0, 0), new Vector2(this.viewOriginX, this.viewOriginY), scale ); this.initLayers(); this.initElements(); },
getTexture: function() { return Assets.Texture(Assets.Images.SPHERE); },
updateTrigger: function() { this.triggerButton.texture = Assets.Texture(this.getTrigger()); this.ray.visible = this.model.get('on'); },
createRightFace: function(points) { return PIXI.createTexturedPolygonFromPoints(points, Assets.Texture(Assets.Images.BRICK_TEXTURE_RIGHT)); },
getTexture: function() { return Assets.Texture(Assets.Images.PHOTON); },