Game Development Reference
In-Depth Information
image:fillRect(-70,-70,150,150,1,1,1,1)
image:fillRect( 20,20,50,50,1,0.6,0,1)
gfxQuad = MOAIGfxQuad2D.new ()
gfxQuad:setTexture ( image )
gfxQuad:setRect ( -64,-64,64,64 )
prop = MOAIProp2D.new ()
prop:setDeck ( gfxQuad )
layer:insertProp ( prop )
Loading Images
Images can be loaded onto a MOAIImage object using the load function, as follows:
theImage = MOAIImage.new ()
theImage:load( "myImage2.png" )
Once you've loaded the image, you can perform various functions on it and apply transformations.
Copying Images
You can copy an image from another image using either the copyRect or copyBits function. Note that
copyBits makes a copy of the source (which cannot be scaled or flipped); a rectangular region from
the source can be copied onto the destination at the position passed. Here's an example of using
the copyBits function:
srcImage = MOAIImage.new ()
srcImage:load ( "myImage2.png" )
iWd, iHt = srcImage:getSize()
destImage = MOAIImage.new()
destImage:init(64,64)
destImage:copyBits(srcImage,0,0,0,0,iWd, iHt)
If you want to be able to scale or flip the image, you can use the copyRect function, which copies a
rectangle from the source image to the destination image. You can flip it by reversing the min/max
parameter of the rectangle. This function will draw the source image with the dimensions specified by
srcMin and srcMax onto the destination space as specified by destMin and destMax . If the destination
dimensions are larger, the image is scaled up and if they are smaller, the image is scaled down.
copyRect(source, srcXMin, srcYMin, srcXMax, srcYMax, destXMin, destYMin, destXMax, destYMax, filter)
 
Search WWH ::




Custom Search