Jump to content

Probelm with bitmap


Recommended Posts

Below there is my code, 'where' gesture is an instance of a class that contain a bitmap.



     <script type="text/javascript" src="js/dollar.js"></script>
     <script type="text/javascript" src="js/phaser.min.js"></script>
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
     <script src="js/gesture.js"></script>


        var w = window.innerWidth * window.devicePixelRatio,h = window.innerHeight * window.devicePixelRatio;
        var game = new Phaser.Game(w, h, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });

        var platforms,gesture,ground;
        var solidH = 100,solidW = 100;
        var bmd;

        function preload() {
        /*Imposta limiti di risoluzione 2048x1536 retina display */
        game.scale.maxWidth = 1920;
        game.scale.maxHeight = 1080;

        /*Vogliamo scalare fino a quando possibile, ma proporzionalmente*/
        game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

            game.load.image('forest', 'assets/bksprite.png');
            game.load.image('ground', 'assets/solid.jpg');

    function create() {                   
         platforms = game.add.group();                                                      
         platforms.enableBody = true; 

         ground = platforms.create(0, game.world.height - solidH, 'ground');                    //adesso creiamo il ground
         ground.body.immovable = true;                                                      // questo impedisce la caduta del ground

         bmd = game.add.bitmapData(w,h);
         bmd.context.fillStyle = '#00CCFF';

         bmd.context.fillStyle = '#FFFFFF';
         background = game.add.tileSprite(0, 0,w,h,bmd); 
        var k=10;
    function update() {
         bmd.context.fillStyle = '#FFFFFF';
         bmd.context.fillRect(k,10, 10, 10); 
        function render(){





I don't understand because the square is drawn  once.

I obtain one white square at position x=10 y=10 and not a line.


Link to comment
Share on other sites


  • Recently Browsing   0 members

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