~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to app-squix/squix/InnerMonster.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 (c) edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package squix;
 
7
 
 
8
import mathx.Point2;
 
9
import mathx.Geometry;
 
10
 
 
11
 
 
12
/**
 
13
 * Combines the IMCombined and the main game logic for collision
 
14
 */
 
15
class InnerMonster extends GameObject
 
16
{
 
17
        var container : IMCombined;
 
18
        
 
19
        public function new( game : Game, sprite : InnerMonsterSprite )
 
20
        {
 
21
                container = new IMCombined( game.global, sprite );
 
22
                
 
23
                super( game );
 
24
                setMonster();
 
25
                game.corePanel.addActor( container );
 
26
                game.corePanel.sizeActor( container, game.global.surfaceSize.promoteF() );
 
27
                 
 
28
                container.place( Point2.at( game.surface.width / 2, game.surface.height / 2 ) );
 
29
 
 
30
                oc = new flashx.ObjectCollider( flash.Lib.current.stage );
 
31
        }
 
32
        
 
33
        override function destroy()
 
34
        {
 
35
                super.destroy();
 
36
                game.corePanel.removeActor( container );
 
37
        }
 
38
        
 
39
        var oc : flashx.ObjectCollider;
 
40
        function posOkay()
 
41
        {
 
42
                //determine if we are okay, either using the simple mode, or the complex mode
 
43
                if( game.innerMonsterOverlap )
 
44
                        return game.surface.isCovered(container.sAt.floorDemote());
 
45
                else
 
46
                {
 
47
                        //bitmap intersect 
 
48
                        return oc.aContainsB( game.corePanel.surfaceBitmap, container.sprite.getActor() )
 
49
                                && game.surface.isValid( container.sAt.floorDemote() );
 
50
                }
 
51
        }
 
52
        
 
53
        override function _stepTime( elapsed : Float )
 
54
        {
 
55
                container.doStepTime( elapsed, posOkay );
 
56
        }
 
57
        
 
58
        override public function getCorePanelCollisionObject( ) : flash.display.DisplayObject
 
59
        {
 
60
                return container;
 
61
        }
 
62
}