Sha256: 0e7b182b4d9c821272c6fd96a2dde41f9e4d85b0c30aaffff1a424ce456e1d46

Contents?: true

Size: 866 Bytes

Versions: 8

Compression:

Stored size: 866 Bytes

Contents

/*
The limit component constraints a value inside a range.

This can be useful for maps, characters, enemies, boxes etc..

re.e('limit bitmap char.png')
.limit('posX', 0, 10) //limits to 0-10
.limit('health', 0) //minimum 0

//maybe in the future..
//.limit('name', 'ben', 'roger', 'bob') //limits name to one of these
//.limit('name', ['yep', 'beb'])
//.limit('type, [0, 10, 13])
*/

re.c('limit')
.defines('limit',
function(prop){

    var c = arguments;
    //if(re.is(min, 'array')) c = min;
    
    //if(re.is(c[1], 'number')){
        if(this[prop] < c[1]){
            this[prop] = c[1];
        } else if(re.is(c[2]) && this[prop] > c[2]){
            this[prop] = c[2];
        }
    /*} else {
        
        for(var i=1; i<c.length; i++){
            if(this[prop] == c[i]) return this;
        }
        this[prop] = c[1];
    }*/
    return this;
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
entityjs-0.4.4 src/math/limit.js
entityjs-0.4.3 src/math/limit.js
entityjs-0.4.2 src/math/limit.js
entityjs-0.4.1 src/math/limit.js
entityjs-0.4.0 src/math/limit.js
entityjs-0.3.2 src/math/limit.js
entityjs-0.3.1 src/math/limit.js
entityjs-0.3.0 src/math/limit.js