The ENTER_FRAME event is called whenever the screen updates (typically 60 times per second). These are registered using the addEventListener function and cancelled using removeEventListener. To handle events we set up listeners which are just Lua functions. #Gideros get logical dimensions code#Which centres the square on its position (100,200).Įvents occur whenever something happens and the Lua code needs to do something about it. Would imply an anchor point at a corner of the square. For Shapes, the anchor point is wherever we set (0,0) when drawing the shape. For TextFields, the anchor point is at the bottom left corner. globalToLocal is useful for hit testing and, indeed, is called by hitTestPoint to see if a point (x,y) is within the given sprite.įor Bitmaps and primitve shapes (like rectangles etc) the position of the sprite is its central point (we call this the anchor point). Returns the coordinate relative to the centre of sprite H. Similarly, we can discover the local coordinates of a global coordinate, eg, To discover the global coordinates of a point (10,20) relative to H use E.g., to discover the global coordinate of H, use You can convert between local and global coordinates using the localToGlobal and globalToLocal commands. Thus each sprite starts of on top of its parent and with the same rotation and scaling. Note that the default position of each sprite is (0,0), its default rotation is 0 degrees and its default scaling is 1 in both directions. When the parent sprite translates, rotates and scales its children translate, rotate and scale on its surface. We can think of the children of a sprite as drawn on the surface of that sprite. Similarly D:getRotation() returns the relative rotation and D:getScale() returns the x and y scaling relative to the parent. Thus D:getPosition() returns the coordinate of D in the reference frame of its parent, A. So we see rotations are relative also.Īlso sprite position functions operate in local coordinates via the parent sprite. If H is given its own rotation (H:setRotation(20)), then the global rotation of H would be the sum total of the two rotations (in this case 30+20=50 degrees). Since H is drawn on the coordinate system of D, then H will (by default) be rotated like D. Thus we position H down and to the right relative to D. But note the x'' is pointing down and right, not straight across. If we now set the coordinate of H to be (50,0), H is displaced 50 pixels along the x'' coordinate. As seen in the figure, when we rotate D, ( D:setRotation(30)) its coordinate system rotates. The exact same principle applies for rotation and scaling as well. Then C is added as the last (third) child of A. This causes D to move up to first child of A, while E moves to second child of A. Let us now consider what happens if we issue the command:įirstly, since C already has a parent, it is removed from the tree. A sprite is only drawn if it is connected to the display tree, that is, if it is a descendent of stage. Since stage is drawn first, everything overlaps it. H will also overlap D since it is D's child. Also, children are drawn in order so C is drawn before D which is drawn before E implying E will overlap D (etc). This implies parents are drawn first then their children so children always ovrerlap their parents. When Longford draws the scene, it draws stage first then works through the tree recursively. When we add new children using addChild, they are added to the end of the parent's list. Eg C can be accessed using A since it is the first child of A (or alternatively using A:getChildAt(1)). Note that each sprite has exactly one parent in the tree and sprites can be accessed by reference to their parent and child index number (shown in red above). To achieve this tree structure, we could enter these commands (assuming the sprites have already been prepared): stage:addChild(A) The next figure shows a typical display tree. 2 Positioning, rotating and scaling spritesĪ key structure in Longford is the display tree in which sprites are arranged in order.Hd.HardDiskSerialNo = () Īnd then another query to get logical disks. MosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '"įoreach(ManagementObject moDisk in mosDisks.Get()) For example I use the following code to get the physical disk: hd = new HardDrive() I need to find the Hard Disks, and Logical Disks and some information about them. I am currently working on a project where I need to use WMI (Windows Management Interface).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |