problem/ question with my syntax
calderone514

Thanks for developing such an awesome framework, and having such good tutorials. I do have one question that I was wondering if someone could take a look at. I'm doing the firs tutorial on you-tube, and I am having a problem with getting a positive score when I click on my "mole" or (pop) object. Before I entered the second perimeter for getting a negative score --, my positive score was working. If anyone can point out the possible problem, I would be much obliged.  

 

Dan

 

App = function(){    this.load = function()    {                wade.loadImage('pop.png');        wade.loadImage('background.png');        wade.loadImage('rocks.png');                            };        this.init = function()    {        var score = 0;        var scoreText = new TextSprite(score.toString(), '34px Arial', 'red');        var scoreObject = new SceneObject(scoreText);        scoreText.setPosition(-220, 230);        wade.addSceneObject(scoreObject);                var sprite = new Sprite('pop.png', 20);        var pop = new SceneObject(sprite);        wade.addSceneObject(pop);                pop.setPosition(-220, 230);        pop.moveTo(-220, 170, 100);        pop.state = 'down';        pop.onMoveComplete = function()        {            if (pop.state == 'down')            {                pop.state = 'up';                pop.moveTo(-220, 230, 100);            }            else if (pop.state == 'up')            {                pop.state = 'down';                pop.moveTo(-220, 170, 100);            }        };                pop.onMouseDown = function()        {            score++;            scoreText.setText(score);            return true;        };        wade.addEventListener(pop, 'onMouseDown');                var rockSprite = new Sprite('rocks.png', 10);        var background = new Sprite('background.png', 30);        var bkrnd = new SceneObject([rockSprite, background]);        wade.addSceneObject(bkrnd);        bkrnd.onMouseDown = function()        {            score--;            scoreText.setText(score);            return true;                    };        wade.addEventListener(bkrnd, 'onMouseDown');                    };                    };
All 3 Comments
calderone514

I figured it out.

 

I'm really digging this framework. Hooked.

 

----------------------

 

App = function(){    this.load = function()    {                wade.loadImage('pop.png');        wade.loadImage('rock.png');        wade.loadImage('background.png');                                    };        this.init = function()    {        var score = 0;        var scoreText = new TextSprite(score.toString(), '34px Arial', 'red');        var scoreObject = new SceneObject(scoreText);        scoreText.setPosition(-220, 230);        wade.addSceneObject(scoreObject);                var sprite = new Sprite('pop.png', 10);        var pop = new SceneObject(sprite);        wade.addSceneObject(pop);                   pop.setPosition(0, 0);        pop.moveTo(0, -75, 100);        pop.state = 'down';        pop.onMoveComplete = function()        {            if (pop.state == 'down')            {                pop.state = 'up';                pop.moveTo(0, 0, 100);            }            else if (pop.state == 'up')            {                pop.state = 'down';                pop.moveTo(0, -75, 100);            }        };                     pop.onMouseDown = function()        {            score++;            scoreText.setText(score);            return true;        };        wade.addEventListener(pop, 'onMouseDown');                var rockSprite = new Sprite('rock.png', 5);        var background = new Sprite('background.png', 20);        var bkrnd = new SceneObject([rockSprite, background]);        bkrnd.setSpriteOffset(0, {x:0, y:0});        bkrnd.setSpriteOffset(1, {x:0, y:0});                        wade.addSceneObject(bkrnd);        bkrnd.onMouseDown = function()        {            score--;            scoreText.setText(score);            return true;                    };          wade.addEventListener(bkrnd, 'onMouseDown');                    };                    };
Gio

Glad you figured it out.

 

If you want to let us know what it is that you found confusing, we can update or add a note to the tutorials so others will find them easier to follow.

 

Thanks

calderone514
I drew my own assets, and had my top layer with multiple rocks. So I think I was just getting ahead of myself, as I was still on the first tutorial. I made a single square and it worked just fine. And after watching the next few tutorials I felt dumb for posting such a silly question. But I appreciate the reply.
Post a reply
Add Attachment
Submit Reply
Login to Reply