ppzhu.net
域名年龄: 14年8个月18天HTTP/1.1 200 OK 服务器:nginx 访问时间:2013年08月07日 22:05:27 类型:text/html; charset=UTF-8 Transfer-Encoding: chunked 连接:keep-alive X-Pingback: http://ppzhu.net/xmlrpc.php 语言环境:PleskLin 网站编码:UTF-8
该域名无法解析为IP
ppzhu'blogIndexWorkcocos2d-xcocos2d-iphonesparrowas3LifephotoAbout29六涂鸦归类于sparrow | Work参与评论通过SPRenderTexture,可以实现一个图形绘制功能。您可以使用不同的图像与透明度创建有趣的笔刷。1,你的刷子的质地和你的画布。2,创建画布,SPImage,用SPRenderTexture创建位图源(类似as3中的bitmapdata)。3,然后,通过触摸事件,来对画布进行涂鸦操作。4,创建个简单的按钮,清理画布#import "SparrowPainting.h"#import "Sparrow.h"@implementation SparrowPainting- (id)init{if ((self = [super init])){numStep = 5.0;brush = [SPImage imageWithContentsOfFile:@"brush.png"];[brush retain];//创建纹理容器,类似创建个bitmapdatacanvasTexture = [[SPRenderTexture alloc] initWithWidth:320 height:480];[canvasTexture clearWithColor:0x000000 alpha:1];//创建图形容器,类似创建个bitmapcanvasImage = [SPImage imageWithTexture:canvasTexture];//创建按钮SPTexture *texture = [[SPTexture alloc] init];button = [SPButton buttonWithUpState:texture text:@"Clear"];SPRectangle *textBounds = [SPRectangle rectangleWithX:0 y:0 width:60 height:20];button.textBounds = textBounds;button.x = 20;button.y = 20;[button setFontColor:0xFFFFFF];[button addEventListener:@selector(onClear:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];[self addChild:canvasImage];[self chanegeBrushColor:0xFF0000];[self addChild:button];//添加事件[self addEventListener:@selector(update:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME];[self addEventListener:@selector(touched:) atObject:self forType:SP_EVENT_TYPE_TOUCH];}return self;}-(void) dealloc{[self addEventListener:@selector(update:) atObject:self forType:SP_EVENT_TYPE_ENTER_FRAME];[self addEventListener:@selector(touched:) atObject:self forType:SP_EVENT_TYPE_TOUCH];[button addEventListener:@selector(onClear:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];[brush release];[button release];[canvasTexture release];[self removeChild:canvasImage];[super dealloc];}-(void) update:(SPEnterFrameEvent *)event{if(NO == drawing) return;double incX = (newTouch.x - lastTouch.x)/numStep;double incY = (newTouch.y - lastTouch.y)/numStep;brush.x = lastTouch.x - (brush.width*0.5);brush.y = lastTouch.y - (brush.height*0.5);for (int i=0; i<numStep; i++) {[canvasTexture drawObject:brush];brush.x += incX;brush.y += incY;}lastTouch = CGPointMake(newTouch.x, newTouch.y);}-(void) touched:(SPTouchEvent *)event{SPPoint *touchPosition;//开始接触SPTouch *touchStart = [[event touchesWithTarget:self andPhase:SPTouchPhaseBegan] anyObject];if (touchStart) {//获取本地位置相对于当前舞台touchPosition = [touchStart locationInSpace:self];lastTouch = CGPointMake(touchPosition.x, touchPosition.y);newTouch = CGPointMake(touchPosition.x, touchPosition.y);uint color = random()* 0xffffff + 0xff0000;[self chanegeBrushColor:color];}//移动SPTouch *touchMove = [[event touchesWithTarget:self andPhase:SPTouchPhaseMoved] anyObject];if (touchMove) {touchPosition = [touchMove locationInSpace:self];newTouch = CGPointMake(touchPosition.x, touchPosition.y);drawing = YES;}//停止接触SPTouch *touchEnd = [[event touchesWithTarget:self andPhase:SPTouchPhaseEnded] anyObject];if (touchEnd) {touchPosition = [touchEnd locationInSpace:self];lastTouch = CGPointMake(touchPosition.x, touchPosition.y)
© 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询
2024-08-07 16:54, Process in 0.0055 second.