~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to app-tutorial/tutorial/Layout1.hx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package tutorial;
 
7
 
 
8
/**
 
9
 * This class demonstrates a basic stage layout.
 
10
 */
 
11
class Layout1 extends ui.StageLayout
 
12
{
 
13
 
 
14
        public function new() 
 
15
        {
 
16
                super();
 
17
        }
 
18
        
 
19
        /**
 
20
         * _resize will be called whenever the stage size changes. 
 
21
         * Overriding this function allows you to handle those
 
22
         * resizes.
 
23
         * In our case we are simple going to draw a few objects
 
24
         * on the screen (to demonstrate different principles)
 
25
         */
 
26
        override function _resize( w : Float, h : Float )
 
27
        {
 
28
                //if you are used to the Flash API you'll notice that we are
 
29
                //using "gfx" here rather than "graphics" directly.  This
 
30
                //is covered in the drawing tutorials
 
31
                gfx.clear();
 
32
                
 
33
                //draw a blue square, which is *always* square, based on the
 
34
                //width -- it never distorts based on the size
 
35
                gfx.use( draw.Brush.solid( draw.Color.rgb( 0, 0, 1 ) ) );
 
36
                gfx.drawRect( w/10, h/10, w/10, w/10 );
 
37
                
 
38
                //draw red rectangle which is proportional to the width
 
39
                //and the height of the stage
 
40
                gfx.use( draw.Brush.solid( draw.Color.rgb( 1, 0, 0 ) ) );
 
41
                gfx.drawRect( w/10, 8*h/10, w/10, h/10 );
 
42
        }
 
43
        
 
44
        /**
 
45
         * The following main function must always be defined if
 
46
         * you wish to use a class as the main layout class.  There
 
47
         * is unfortunately no simple way to have this automatically
 
48
         * done by haxe.
 
49
         */
 
50
        static public function main()
 
51
        {
 
52
                ui.StageLayout.setup( Layout1 );
 
53
        }
 
54
}