PXTexture Class Reference
| Inherits from | PXDisplayObject : PXEventDispatcher : NSObject |
| Declared in | PXTexture.h PXTexture.m |
Overview
Used for drawing PXTextureData objects to the screen. A PXTexture is a subclass of the PXDisplayObject which can be specified to render an entire texture or just a specific area.
Tasks
-
textureDataThe texture data that this texture represents.
property -
clipRectThe clip area of the texture data that this texture is representing. To show the entire image, set this property to nil.
property -
anchorXThe horizontal anchor position in percent. If the texture was 32x64 and you set the anchor to 0.5f, the horizontal position in point coordinates would be 16. The anchor position is what the texture will rotate, scale, and position around.
property -
anchorYThe vertical anchor position in percent. If the texture was 32x64 and you set the anchor to 0.5f, the vertical position in point coordinates would be 32. The anchor position is what the texture will rotate, scale, and position around.
property -
smoothingDetermines whether pixel smoothing will be turned on when the texture is scaled or rotated. Note that while smoothing looks better it is also more taxing on the gpu.
property -
repeatDetermines how pixels outside of the texture’s boundaries should be handled. If the clipRect of the texture is outside of the bounds of the texture, setting repeat to
propertyYESwill simply repeat the texture’s pixels to fill the gap. If set toNO, the 1-pixel boundary around the edge of will be stretched to fill the gap. -
contentWidthThe width of the clipping area, or of the textureData property if no clipping area is set.
property -
contentHeightThe height of the clipping area, or of the textureData property if no clipping area is set.
property -
contentRotationThe rotation offset of the content, as defined by the texture’s clip rectangle.
property -
– initWithTextureData:Creates a texture that represents the specified texture data.
-
– setAnchorWithPointX:pointY:Sets anchor position in points, relative to the current textureData. If textureData is
nil, this method call is ignored. -
– setClipRectWithX:y:width:height:Sets the clip area and anchor point in one call.
-
+ texture/
-
+ textureWithTextureData:Creates an autoreleased PXTexture object with the given PXTextureData object
-
+ textureWithContentsOfFile: -
+ textureWithContentsOfFile:modifier: -
+ textureWithContentsOfURL: -
+ textureWithContentsOfURL:modifier: -
+ textureWithData: -
+ textureWithData:modifier:
Properties
anchorX
The horizontal anchor position in percent. If the texture was 32x64 and you set the anchor to 0.5f, the horizontal position in point coordinates would be 16. The anchor position is what the texture will rotate, scale, and position around.
@property (nonatomic, assign) float anchorXDeclared In
PXTexture.hanchorY
The vertical anchor position in percent. If the texture was 32x64 and you set the anchor to 0.5f, the vertical position in point coordinates would be 32. The anchor position is what the texture will rotate, scale, and position around.
@property (nonatomic, assign) float anchorYDeclared In
PXTexture.hclipRect
The clip area of the texture data that this texture is representing. To show the entire image, set this property to nil.
@property (nonatomic, copy) PXClipRect *clipRectDiscussion
Since the clip rectangle is closely tied to the textureData, if the textureData property is nil, this property will remain nil. Also, setting the textureData property wipes out the current clipRect, so make sure to set the clipRect AFTER setting the textureData property.
Thus if the texture is 256x256 pixels, and you only want a 32x64 segment, the clip rect is what would be set to achieve this.
Declared In
PXTexture.hcontentHeight
The height of the clipping area, or of the textureData property if no clipping area is set.
@property (nonatomic, readonly) float contentHeightDeclared In
PXTexture.hcontentRotation
The rotation offset of the content, as defined by the texture’s clip rectangle.
@property (nonatomic, readonly) float contentRotationDiscussion
default 0
Declared In
PXTexture.hcontentWidth
The width of the clipping area, or of the textureData property if no clipping area is set.
@property (nonatomic, readonly) float contentWidthDeclared In
PXTexture.hrepeat
Determines how pixels outside of the texture’s boundaries should be handled.
If the clipRect of the texture is outside of the bounds of the texture,
setting repeat to YES will simply repeat the texture’s pixels
to fill the gap. If set to NO, the 1-pixel boundary around the
edge of will be stretched to fill the gap.
@property (nonatomic, assign) BOOL repeatDeclared In
PXTexture.hClass Methods
textureWithContentsOfFile:
+ (PXTexture *)textureWithContentsOfFile:(NSString *)pathDeclared In
PXTexture.mtextureWithContentsOfFile:modifier:
+ (PXTexture *)textureWithContentsOfFile:(NSString *)path modifier:(id<PXTextureModifier>)modifierDeclared In
PXTexture.mtextureWithContentsOfURL:
+ (PXTexture *)textureWithContentsOfURL:(NSURL *)urlDeclared In
PXTexture.mtextureWithContentsOfURL:modifier:
+ (PXTexture *)textureWithContentsOfURL:(NSURL *)url modifier:(id<PXTextureModifier>)modifierDeclared In
PXTexture.mtextureWithData:modifier:
+ (PXTexture *)textureWithData:(NSData *)data modifier:(id<PXTextureModifier>)modifierDeclared In
PXTexture.mInstance Methods
initWithTextureData:
Creates a texture that represents the specified texture data.
- (id)initWithTextureData:(PXTextureData *)_textureDataParameters
- texture
The texture data that this texture represents.
Example:
PXTextureLoader *loader = [[PXTextureLoader alloc] initWithContentsOfFile:@"happy.png"]; PXTextureData *data = [loader newTextureData]; PXTexture *tex = [[PXTexture alloc] initWithTextureData:data];
See Also
Declared In
PXTexture.msetAnchorWithPointX:pointY:
Sets anchor position in points, relative to the current textureData.
If textureData is nil, this method call is ignored.
- (void)setAnchorWithPointX:(float)x pointY:(float)yParameters
- x
The horizontal anchor position in points, within the textureData.
- y
The vertical anchor position in points, within the textureData.
Example:
PXTextureLoader *loader = [[PXTextureLoader alloc] initWithContentsOfFile:@"happy.png"]; PXTextureData *data = [loader newTextureData]; PXTexture *tex = [[PXTexture alloc] initWithTextureData:data]; [tex setAnchorWithPointX:16 pointY:32]; // tex would represent the happy image. Assuming happy is a 32x64 image, // then its anchor will be at (16, 32) in local point coordinates.
See Also
Declared In
PXTexture.msetClipRectWithX:y:width:height:
Sets the clip area and anchor point in one call.
- (void)setClipRectWithX:(float)x y:(float)y width:(float)width height:(float)heightParameters
- x
The left position of the clip rectangle in points.
- y
The top position of the clip rectangle in points.
- width
The width of the clip rectangle in points.
- height
The height of the clip rectangle in points.
- anchorX
The horizontal anchor position, in percent.
- anchorY
The vertical anchor position, in percent.
Example:
PXTextureLoader *loader = [[PXTextureLoader alloc] initWithContentsOfFile:@"happy.png"]; PXTextureData *data = [loader newTextureData]; PXTexture *tex = [[PXTexture alloc] initWithTextureData:data]; [tex setClipRectWithX:16 y:16 width:32 height:64 usingAnchorX:0.5f anchorY:0.5f]; // tex would represent a 32x64 image that is part of the whole image of // happy, starting at (16, 16). Its anchor will be at (16, 32) in local // point coordinates.
See Also
Declared In
PXTexture.m