Canvas creates areas that cannot be drawn

Asked 1 years ago, Updated 1 years ago, 36 views

I have specified width 1024, height 768 in GameApp, but when I actually draw, I can only draw up to width 800.
What are the possible causes of this?

phina.define('MainScene', {
    superClass: 'DisplayScene',
    init:function(){
        This.superInit();

        for (varrow=0; row<32;row++){
            for(varcol=0;col<48;col++){
                varchipImage="ground";
                if(row%2==0&col%2==0){
                    chipImage="grassland"
                }
                this.bg=Sprite(chipImage).addChildTo(this);
                this.bg.setPosition(32*col,32*row);
                this.bg.origin.set(0,0);
            }
        }
    },
});

// main processing
phina.main(function(){
    var app = GameApp({
        startLabel: 'main',
        width: 1024,
        height —768,
        assets —ASSETS
    });

    app.enableStats();
    app.run();
});

javascript

2022-09-30 21:26

1 Answers

Just give the width and height to Scene!

phina.define('MainScene', {
    superClass: 'DisplayScene',
    init:function(){
        This.superInit (// Give Scene width, height too!)
            {
                width: 1024,
                height768
            }
        );

        for (varrow=0; row<32;row++){
            for(varcol=0;col<48;col++){
                varchipImage="ground";
                if(row%2==0&col%2==0){
                    chipImage="grassland"
                }
                this.bg=Sprite(chipImage).addChildTo(this);
                this.bg.setPosition(32*col,32*row);
                this.bg.origin.set(0,0);
            }
        }
    },
});

// main processing
phina.main(function(){
    var app = GameApp({
        startLabel: 'main',
        width: 1024,
        height —768,
        assets —ASSETS
    });

    app.enableStats();
    app.run();
});


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.