void HelloWorld::createParticleEffect(const char* filename, float x, float y, ccColor4F startColor, float duration, float endSize) {
     CCParticleSystem* emitter = CCParticleSystemQuad::create(filename);
     emitter->setPosition(x,y);
     emitter->setStartColor(startColor);
     emitter->setDuration(duration);
     emitter->setEndSize(endSize);
     emitter->setAutoRemoveOnFinish(true);
     addChild(emitter, 10);
}
예제 #2
0
CCParticleSystem* ParticleLayer::createExplodingRing()
{
	CCParticleSystem *emitter = new CCParticleSystemQuad();
	emitter->initWithFile("Particles/ExplodingRing.plist");
	emitter->setAutoRemoveOnFinish(true);
//	emitter->setEndRadius(100.0f);

	addChild(emitter, 10);

	return emitter;
}
예제 #3
0
CCParticleSystem* ParticleLayer::createExplosion()
{
	CCParticleSystem *emitter = CCParticleExplosion::create();
	emitter->retain();
	addChild(emitter, 10);

	emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("Particles/stars.png") );

	emitter->setAutoRemoveOnFinish(true);

	return emitter;
}
예제 #4
0
void TestParticle::initExplosion()
{
	CCParticleSystem *emitter = CCParticleExplosion::create();
	emitter->retain();
	addChild(emitter, 10);

	emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("stars.png") );

	emitter->setAutoRemoveOnFinish(true);

	emitter->setPosition(ccp(400,50));
	emitter->release();
}
예제 #5
0
CCParticleSystem* ParticleLayer::createFireWorks()
{
	CCParticleSystem *emitter = CCParticleFireworks::create();
	emitter->retain();
	emitter->setGravity(CCPointZero);
	addChild(emitter, 10);

	emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("Particles/stars.png") );

	emitter->setAutoRemoveOnFinish(true);

	return emitter;
}
void HelloWorld::createParticleEffect(const char* filename, float x, float y) {
     CCParticleSystem* emitter = CCParticleSystemQuad::create(filename);
     emitter->setPosition(x,y);
     emitter->setAutoRemoveOnFinish(true);
     addChild(emitter, 10);
}
예제 #7
0
void HelloWorld::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
	CCNode* node = this->getChildByTag(TileMapNode);	
	//NSAssert([node isKindOfClass:[CCTMXTiledMap class]], @"not a CCTMXTiledMap");
	CCTMXTiledMap* tileMap = (CCTMXTiledMap*)node;
	
	// get the position in tile coordinates from the touch location
	CCPoint touchLocation = this->locationFromTouch((cocos2d::CCTouch *)pTouches->anyObject());	
	CCPoint tilePos = this->tilePosFromLocation(touchLocation, tileMap);	

	//// move tilemap so that touched tiles is at center of screen
	this->centerTileMapOnTileCoord(tilePos, tileMap);

	// Check if the touch was on water (eg. tiles with isWater property drawn in GameEventLayer)
	bool isTouchOnWater = false;	
	CCTMXLayer* eventLayer = tileMap->layerNamed("GameEventLayer");
	int tileGID = eventLayer->tileGIDAt(tilePos);	
	//
	if (tileGID != 0) {
		CCDictionary* properties = tileMap->propertiesForGID(tileGID);
		if (properties) {
			//CCLOG(@"NSDictionary 'properties' contains:\n%@", properties);	
			const CCString * isWaterProperty = properties->valueForKey("isWater");
			isTouchOnWater = isWaterProperty->boolValue();			
		}
	}
	
	// Check if the touch was within one of the rectangle objects
	CCTMXObjectGroup* objectLayer = tileMap->objectGroupNamed("ObjectLayer");
	//NSAssert([objectLayer isKindOfClass:[CCTMXObjectGroup class]], 
	//		 @"ObjectLayer not found or not a CCTMXObjectGroup");
	
	bool isTouchInRectangle = false;
	int numObjects = objectLayer->getObjects()->count();
	for (int i = 0; i < numObjects; i++){
		CCDictionary* properties = (CCDictionary*)objectLayer->getObjects()->objectAtIndex(i);
		CCRect rect = this->getRectFromObjectProperties(properties, tileMap);
		//	
		if (CCRect::CCRectContainsPoint(rect, touchLocation)) {
			isTouchInRectangle = true;
			break;
		}
	}
	
	// decide what to do depending on where the touch was ...
	if (isTouchOnWater) {
		//[[SimpleAudioEngine sharedEngine] playEffect:@"alien-sfx.caf"];
		CCLog("touchOnWater");
	}
	else if (isTouchInRectangle) {
		CCLog("touchObject");
		CCParticleSystem* system = CCParticleSystemQuad::particleWithFile("fx-explosion.plist");
		system->setAutoRemoveOnFinish(true);
		system->setPosition(touchLocation);
		this->addChild(system, 1);
	}
	else {

#if 0
		// get the winter layer and toggle its visibility
		CCTMXLayer* winterLayer = tileMap->layerNamed("WinterLayer");
		winterLayer->setVisible(!winterLayer->isVisible());
		
		// other options you might be interested in are:	

		// remove the touched tile		
		winterLayer->removeTileAt(tilePos);		
		// add a specific tile
		tileGID = winterLayer->tileGIDAt(CCPointMake(0, 19));
		winterLayer->setTileGID(tileGID, tilePos);
#endif

	}
}