SHClippedSprite

type:
extension
author:
Shilo White
description:
A simple clipped sprite.
lastupdate:
2011-06-04
compatible:
v1.X
tag:
clip, sprite, clippedsprite
homepage:
https://gist.github.com/1346513
download:
https://gist.github.com/gists/1346513/download
min iOS version:
3.2

Description

SHClippedSprite class will allow you to easily clip children (display objects) inside of a sprite. This class inherits all properties from SPSprite and also includes:

@property (nonatomic, readonly) SPQuad *clip;
Default properties:
clip.x = 0
clip.y = 0
clip.width = 0
clip.height = 0
 
@property (nonatomic, assign) BOOL clipping;
Default value is NO.

Sample

(Coming later)

Example

SHClippedSprite *cp = [[SHClippedSprite alloc] init];
cp.clip.x = 5;
cp.clip.y = 10;
cp.clip.width = 100;
cp.clip.height = 80;

Instructions

To add into your Sparrow project

  1. Open your desired Sparrow project
  2. Drag and drop the files into the “Groups & Files” pane
  3. Open “Game.h”
  4. Include the extension:
    #include "SHClippedSprite.h"
  5. Save “Game.h”

To add directly into Sparrow source

  1. Save the files into Sparrow's “/Classes/” directory
    • Example: “/sparrow/src/Classes/”
  2. Navigate back one directory and open “Sparrow.xcodeproj”
    • Example: “/sparrow/src/Sparrow.xcodeproj”
  3. Inside the “Groups & Files” pane, locate the “Display” group folder
    • Example: “Sparrow → Classes → Display”
  4. Right click the “Display” group folder and click “Add → Existing Files..”
  5. Navigate into the “/Classes/” directory and select “SHClippedSprite.h” and “SHClippedSprite.m”, then click “add”
  6. On the next window, leave all options as default and click “add”
  7. In the “Groups & Files” pane, Open “Sparrow.h”
    • Example “Sparrow → Classes → Sparrow.h”
  8. At the bottom of the file, add:
    #import "SHClippedSprite.h"
  9. Save “Sparrow.h”
  10. Close “Sparrow.xcodeproj”

Source Code

Changelog

  • 2011-06-04: First version
  • 2011-06-12: Fixed clipped bounds.

Todo

  • (Empty)
  users/shilo/extensions/shclippedsprite.txt · Last modified: 2014/04/24 13:05 by 178.219.160.178
 
Powered by DokuWiki