Sunday, 2 June 2013

Error returning a value from a function?

Error returning a value from a function?

It tells me the error is on this line: this.srcX = ShipSrcXPicker(type);
However I cannot see it? I am returning the values from these methods that are being called? Is there something I am missing? I am making a Object and drawing the image to the screen?
function Player()  //Object
{

this.PlayerHullMax = 1000;
this.PlayerHull = 1000;
 this.PlayerShieldMax = 1000;
this.PlayerShield = 347;
this.Experience = 2684;

//where on canvas memory
this.type = "Cruiser";
this.srcX = ShipSrcXPicker(type);
this.srcY = ShipSrcYPicker(type);
this.drawX = ShipdrawXPicker(type);
this.drawY = ShipdrawYPicker(type);
this.playerWidth = ShipWidthPicker(type);
this.playerHeight = ShipHeightPicker(type);
}

Player.prototype.draw = function()
{
ClearShipsCanvas();
ctxShips.globalAlpha=1;
 ctxShips.drawImage(spriteImage,this.srcX,this.srcY,this.playerWidth,this.playerHeight,this. drawX,this.drawY,this.playerWidth,this.playerHeight);
 };

function ShipSrcXPicker(type)
{
if (type == "Cruiser")

 {
    return 0;
 }
 }

function ShipSrcYPicker(type)
{
if (type == "Cruiser")

 {
    return 1385;
 }
}

function ShipdrawXPicker(type)
{
 if (type == "Cruiser")

 {
    return 100;
 }
}

function ShipdrawYPicker(type)
{
if (type== "Cruiser")

 {
    return 400;
 }
}


function ShipWidthPicker(type)
{
if (type == "Cruiser")

 {
    return 150;
 }
}

function ShipHeightPicker(type)
{
if (type == "Cruiser")

 {
    return 90;
 }
}

No comments:

Post a Comment