Advertisement
Guest User

Untitled

a guest
Jul 7th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.07 KB | None | 0 0
  1.     // Set graphic colour  
  2.         for (key => state in just_pressed.active) {
  3.                 if (!state) {
  4.                     display.color = display.init_color;
  5.                     continue;
  6.                 }
  7.                 display.color = switch (key) {
  8.                     case Left: Color.Red;
  9.                     case Right: Color.Red;
  10.                     case Down: Color.Red;
  11.                     case Up: Color.Red;
  12.                     default: Color.Transparent;
  13.                 }
  14.  
  15.                 if (key == Left) {
  16.                     trace('Left: ' + display.color);
  17.                 }
  18.                 if (key == Right) {
  19.                     trace('Right: ' + display.color);
  20.                 }
  21.                 if (key == Up) {
  22.                     trace('Up: ' + display.color);
  23.                 }
  24.                 if (key == Down) {
  25.                     trace('Down: ' + display.color);
  26.                 }              
  27.             }  
  28. // Render loop
  29.     override function update() {
  30.  
  31.         if (Game.framebuffer == null) {
  32.             return;
  33.         }
  34.  
  35.         var graphics = Game.framebuffer.g2;
  36.         graphics.begin();
  37.  
  38.         for (node in this.display_id) {
  39.             var position = this.position.get(node);
  40.             var display = this.display.get(node);
  41.            
  42.             graphics.color = display.color;
  43.             trace(graphics.color);
  44.             graphics.fillRect(position.x, position.y, display.width, display.height);      
  45.         }
  46.  
  47.         graphics.end();
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement