sbiermanlytle / iioEngine

iio Engine: A JavaScript game engine for HTML5 Canvas
http://iioengine.com
455 stars 81 forks source link

Undefined is not a function (when I'm trying to delete an object) #32

Closed lcnvdl closed 9 years ago

lcnvdl commented 10 years ago

Hello! I'm getting an error when I'm trying to delete an object.

First, this is my problem: error

The "obj" doesn't contains the method clearSelf. Is undefined.

This is how I create and delete the object:

this.__showGunScan = function(dist) {
        var r = this.robot,
            x = r.x,
            y = r.y,
            a = r.gunAngle,
            d = Math.pointDir(a, dist)
        ;

        // THIS IS THE OBJECT
        var l = io.addToGroup('sensors', new iio.Line(x, y, x, y)
            .setStrokeStyle('red',2), -20
        );

        var tween = new TWEEN.Tween( { x: 0, y: 0 } )
            .to( d, 1000 + dist )
            .easing( TWEEN.Easing.Linear.None )
            .onUpdate( function () {
                l.pos.set(r.x, r.y);
                l.endPos.set(r.x + this.x, r.y + this.y);

            })
            .onComplete( function() {
                io.rmvObj(l);    // HERE I DELETE THE OBJECT
            })
            .start();
    };

Can you help me to solve this?

Thank you very much

sbiermanlytle commented 10 years ago

Sorry for the delayed support, I was on vacation in Canada and had limited internet.

I think I solved the problem - the clearDraw function was never implemented for the Line object for some reason.

Download the updated file here: https://github.com/sbiermanlytle/iioengine/tree/master/archives/1.2/core

and let me know if there is still a problem

lcnvdl commented 10 years ago

Thanks! downloading...