Jump to content

Syntax Validation Question


Ninjadoodle
 Share

Recommended Posts

Hi @enpu

I'm trying to figure out what I'm doing wrong here. I have Syntax Validation turned on and have no errors / warnings in any of my modules.

In my 'objects' module however, I get a warning that says '78% scanned  - too many errors'

I have tried deleting randoms blocks of code, and the warning goes away - but I have no idea what's causing it in the first place.

I don't really see any errors in my file, so just wondering what I can do here.

I'm posting my code for reference ...

game.module(
    'game.objects'
)
.body(function() {



// SOUND FX
    
    
// LANDSCAPE SWITCH
game.System.inject({
    
    _updateWindowSize: function() {
        this.super();
        if (game.device.iPhone && window.innerWidth > window.innerHeight && window.innerHeight === window.screen.width) {
            this._windowHeight++;
        }
        if (game.device.iPhone) document.body.scrollTop = 0;
    }
});



// TRANSITION
game.createClass('StarSpin', {
    
    init: function(stage) {
        
        game.scene.solved = true;
        
        this.sprite1 = new game.Graphics();
        this.sprite1.fillColor = '#000000';
        this.sprite1.drawRect(0, 0, 1280, 2560);
        this.sprite1.anchorCenter();
        this.sprite1.addTo(game.scene.tv);
        this.sprite1.position.set(640, 960);
        this.sprite1.alpha = 0;
        
        this.sprite2 = new game.Graphics();
        this.sprite2.fillColor = '#ffffff';
        this.sprite2.drawRect(0, 0, 1280, 2560);
        this.sprite2.anchorCenter();
        this.sprite2.addTo(game.scene.tv);
        this.sprite2.position.set(640, 960);
        this.sprite2.alpha = 0;
        
        this.sprite3 = new game.Sprite('star.png');
        this.sprite3.position.set(640, 960);
        this.sprite3.anchorCenter();
        this.sprite3.addTo(game.scene.tv);
            
        game.Tween.add(this.sprite1, {
            alpha: 1
        }, 250, {
            delay: 100
        }).start();
        
        game.Tween.add(this.sprite2, {
            alpha: 1
        }, 250, {
            delay: 350
        }).onComplete(function() {
            game.system.setScene(stage);
        }).start();
        
        game.Tween.add(this.sprite3.scale, {
            x: 2,
            y: 2
        }, 500, {
            delay: 100
        }).start();
        
        game.Tween.add(this.sprite3, {
            rotation: 6,
            easing: 'Quadratic.In'
        }, 500, {
            delay: 100
        }).start();
    }
});



// BUTTON PLAY
game.createClass('ButtonPlay', {
    
    init: function(x, y, scene) {
        
        this.sprite = new game.Sprite('buttonPlay.png');
        
        this.sprite.mousedown = function() {
            
            if (!touched) {
                
                game.audio.playSound('pop');
                this.scale.set(0.75);
                touched = true;
                
                game.Tween.add(this.scale, {
                    x: 1,
                    y: 1
                }, 200, {
                    delay: 100,
                    easing: 'Elastic.Out'
                }).start();
                
                game.Tween.add(game.scene.transition.sprite, {
                    alpha: 1
                }, 200, {
                    delay: 100
                }).onComplete(function() {
                    game.system.setScene(scene);
                }).start();
                
            }
        };
        
        this.sprite.interactive = true;
        this.sprite.position.set(x, y);
        this.sprite.anchorCenter();
        this.sprite.addTo(game.scene.mg);
    }
});



// BG CIRCLE
game.createClass('BgCircle', {
    
    init: function() {
        
        this.sprite = new game.Sprite('bgCircle.png');
        
        this.sprite.position.set(160, 160);
        this.sprite.anchorCenter();
        this.sprite.alpha = 0.075;
        this.sprite.addTo(game.scene.fg);
        
        game.Tween.add(this.sprite.scale, {
            x: 0.95,
            y: 0.95
        }, 1000, {
            easing: 'Quadratic.InOut',
            repeat: Infinity,
            yoyo: true
        }).onComplete(function() {
            game.scene.fg.removeChild(this);
        }).start();
    }
});



// SETTING MENU
game.createClass('SettingsScreen', {
    
    init: function() {
       
        this.sprite = new game.Graphics();
        this.sprite.fillColor = '#000000';
        this.sprite.drawRect(0, 0, 1280, 1920);
        this.sprite.anchorCenter();
        this.sprite.addTo(game.scene.ui);
        this.sprite.position.set(640, 960);
        this.sprite.interactive = false;
        
        this.sprite.alpha = 0.5;
    }
});



game.createClass('ButtonSettings', {
    
    init: function() {
        
        this.sprite = new game.Sprite('buttonSettings.png');
        
        this.sprite.position.set(1280, 0);
        this.sprite.anchor.set(192, 0);
        this.sprite.interactive = true;
        this.sprite.addTo(game.scene.fg);
        
        this.sprite.mousedown = this.mousedown.bind(this);
    },
    
    mousedown: function() {
        
        game.Timer.speed = 0;
        
        this.sprite.visible = false;
        game.scene.ui.visible = true;
        game.scene.settingsScreen.sprite.interactive = true;
        game.scene.settingsButtonBack.sprite.interactive = true;
    }
});



game.createClass('ButtonSettingsBack', {
    
    init: function() {
        
        this.sprite = new game.Sprite('buttonSettingsBack.png');
        
        this.sprite.position.set(640, 960);
        this.sprite.anchorCenter();
        this.sprite.interactive = false;
        this.sprite.addTo(game.scene.ui);
        
        this.sprite.mousedown = this.mousedown.bind(this);
    },
    
    mousedown: function() {
        
        game.Timer.speed = 1;
        
        game.scene.settingsScreen.sprite.interactive = false;
        game.scene.buttonSettings.sprite.interactive = true;
        game.scene.buttonSettings.sprite.visible = true;
        
        this.sprite.interactive = false;
        game.scene.ui.visible = false;
    }
});



game.createClass('ButtonSettingsMusic', {
    
    init: function() {
        
        this.sprite = new game.Sprite('buttonSettingsMusic.png');
        
        this.sprite.position.set(320, 1472);
        this.sprite.anchorCenter();
        this.sprite.interactive = false;
        this.sprite.addTo(game.scene.ui);
        
        this.sprite.mousedown = this.mousedown.bind(this);
    },
    
    mousedown: function() {
        this.sprite.interactive = false;
    }
});



game.createClass('ButtonSettingsSfx', {
    
    init: function() {
        
        this.sprite = new game.Sprite('buttonSettingsSfx.png');
        
        this.sprite.position.set(640, 1472);
        this.sprite.anchorCenter();
        this.sprite.interactive = false;
        this.sprite.addTo(game.scene.ui);
        
        this.sprite.mousedown = this.mousedown.bind(this);
    },
    
    mousedown: function() {
        this.sprite.interactive = false;
    }
});




// LEVEL SETUP
game.createClass('StageSetup', {

    setupStage: function() {
        
        // RESET GLOBALS
        solved = false;
        
        // SETUP CONTAINERS
        game.scene.tv = new game.Container().addTo(game.scene.stage);
        
        game.scene.gm = new game.Container().addTo(game.scene.tv);
        game.scene.ui = new game.Container().addTo(game.scene.tv);
        game.scene.ui.visible = false;
        
        game.scene.bg = new game.Container().addTo(game.scene.gm);
        game.scene.mg = new game.Container().addTo(game.scene.gm);
        game.scene.fg = new game.Container().addTo(game.scene.gm);
        
        game.scene.shadow = new game.Shadow();
        game.scene.puzzleBg = new game.PuzzleBg();
        game.scene.puzzleFg = new game.PuzzleFg();
        
        var fader = new game.Fader();
        fader.color = 'ffffff';
        fader.speed = 500;
        fader.fadeIn();
        
        // SETUP SETTINGS
        game.scene.buttonSettings = new game.ButtonSettings();
        game.scene.settingsScreen = new game.SettingsScreen();
        game.scene.settingsButtonBack = new game.ButtonSettingsBack();
    },



    containers: function() {
        
        game.scene.tv.position.set(game.system.width / 2 - game.system.originalWidth / 2, game.system.height / 2 - game.system.originalHeight / 2);
        
        game.scene.offsetX = (game.system.width - game.system.originalWidth) / 2;
        game.scene.offsetY = (game.system.height - game.system.originalHeight) / 2;
        
        game.scene.buttonSettingsY = -1* ((game.system.height - game.system.originalHeight) / 2);
        
        game.scene.buttonSettings.sprite.y = game.scene.buttonSettingsY;
    },
    
    
    
    updateStage: function() {
        
        this.containers();
    }
});

});

 

Link to comment
Share on other sites

@Ninjadoodle

I played around with that feature, and you are right it doesn't seem to work as expected.

Actually the term "Syntax Validation" is a bit misleading and should be changed, since it actually just checks for your code formatting and then should give you some hints to keep your code looking good and clean. Your code looks really good to me (except those unnecessary multiple empty lines ;)), so i would not worry. If there would be syntax errors, your game would not even run.

I will fix this for the next release.

Link to comment
Share on other sites

Hi @enpu

Thanks heaps for letting me know. I thought there might be some issues with the validation, as I’ve noticed that some of the Panda game templates don’t fully scan either.

Sometimes I forget to add a semicolon or something along those lines, and the syntax validation works well in those instances.

As far as the empty lines go, I normally put those in, to help me read the code better. I’ll probably change them to ‘comments’ instead, since the gaps are not good practice :)

Thanks again!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...