Exemple #1
0
wyAuroraSprite* wyAuroraSprite::make(int bsResId, int animIndex, wyTexture2D* tex, ...) {
	// create aurora sprite
	wyAuroraSprite* sprite = WYNEW wyAuroraSprite();

	// load anu file data
	sprite->m_aurora = wyAuroraManager::getInstance()->load(bsResId);
	sprite->m_aurora->retain();

	va_list textures;
	va_start(textures, tex);

	// add first
	wySpriteBatchNode* sheet = wySpriteBatchNode::make(tex);
	wyArrayPush(sprite->m_sheetList, sheet);
	sheet->retain();

	// add others
	for(wyTexture2D* t = va_arg(textures, wyTexture2D*); t != NULL; t = va_arg(textures, wyTexture2D*)) {
		sheet = wySpriteBatchNode::make(t);
		wyArrayPush(sprite->m_sheetList, sheet);
		sheet->retain();
	}

	va_end(textures);

	// start animation
	sprite->playAnimation(animIndex);

	// return
	sprite->autoRelease();
	return sprite;
}
Exemple #2
0
wyTMXTileMap* wyTMXTileMap::make(const char* path, bool isFile, wyTexture2D* tex1, ...) {
	wyTMXTileMap* tmx = WYNEW wyTMXTileMap();

	// load tmx file
	wyMapInfo* map = wyTMXLoader::load(path, isFile);

	// collect first texture
	wyArray* textures = wyArrayNew(map->tilesets->num);
	wyArrayPush(textures, tex1);

	// collect other textures
    va_list texList;
    va_start(texList, tex1);
    for(wyTexture2D* now = va_arg(texList, wyTexture2D*); now != NULL; now = va_arg(texList, wyTexture2D*)) {
    	wyArrayPush(textures, now);
    }
    va_end(texList);

    // init
    tmx->init(map, textures);

    // destroy temp list
    wyArrayDestroy(textures);

	return (wyTMXTileMap*)tmx->autoRelease();
}
void wyDirector_android::addLifecycleListener(jobject l) {
    if(l != NULL) {
        JNIEnv* env = wyUtils::getJNIEnv();
        jobject listener = env->NewGlobalRef(l);
        wyArrayPush(m_jLifecycleListeners, listener);
    }
}
Exemple #4
0
void wyBladeRibbon::addPoint(wyPoint location) {
	// if first point and current blade is not NULL, push it to drawing array
	if(m_firstPoint) {
		// let current blade dead
		if(m_blade) {
			wyArrayPush(m_dyingBlades, m_blade);
			m_blade = NULL;
		}
	}

	// get blade allocated if not
	if(!m_blade) {
		if(m_reusableBlades->num > 0)
			m_blade = (wyBlade*)wyArrayPop(m_reusableBlades);
		else {
			m_blade = WYNEW wyBlade(m_texture, m_color, m_fadeTime);
			m_blade->setMaxPointCount(m_maxPointCount);
		}
	}

	// add point
	m_blade->addPoint(location);
	m_firstPoint = false;

	// set flag
	m_blade->m_dirty = true;
}
Exemple #5
0
wyHexagonAStarMap::wyHexagonAStarMap(int width, int height) :
	wyAStarMap(), m_width(width), m_height(height) {

	m_tiles = wyArrayNew(m_width * m_height);
	for (int x = 0; x < m_width; x++) {
		for (int y = 0; y < m_height; y++) {
			wyArrayPush(m_tiles, WYNEW wyAStarTile(TILE_FREE, x, y));
		}
	}

	// auto clilds
	for (int i = 0; i < m_tiles->num; i++) {
		wyAStarTile* tile = (wyAStarTile*) wyArrayGet(m_tiles, i);
		int y_max = (tile->getX() % 2) ? 2 : 1;
		int y_min = (tile->getX() % 2) ? 0 : -1;
		int child_y = (tile->getX() % 2) ? -1 : 1;

		wyAStarTile* neighbor = getTileAt(tile->getX(), tile->getY() + child_y);
		if (neighbor != tile && neighbor != NULL) {
			tile->pushChild(neighbor);
		}

		for (int x = -1; x < 2; x++) {
			for (int y = y_min; y < y_max; y++) {
				neighbor = getTileAt(tile->getX() + x, tile->getY() + y);
				if (neighbor != tile && neighbor != NULL) {
					tile->pushChild(neighbor);
				}
			}
		}
	}
}
Exemple #6
0
void wyDirector::pushScene(wyScene* scene) {
	if(m_nextScene) {
		LOGW("wyDirector::pushScene: next scene is already set, you call pushScene multiple times?");
	} else if(scene != NULL) {
		wyArrayPush(m_scenesStack, scene);
		wyObjectRetain(scene);
		setNextScene(scene);
	}
}
Exemple #7
0
wyResultSet::wyResultSet(wyDatabase* db, wyStatement* statement) :
		m_db(db),
		m_statement(statement),
		m_sql(wyUtils::copy(statement->getQuery())),
		m_columnNames(NULL) {
	// setup column names
    int columnCount = sqlite3_column_count(statement->getStatement());
    m_columnNames = wyArrayNew(columnCount);
    for(int i = 0; i < columnCount; i++) {
    	char* name = (char*)wyUtils::copy(sqlite3_column_name(statement->getStatement(), i));
    	wyUtils::toLowercase(name);
    	wyArrayPush(m_columnNames, name);
    }
}
Exemple #8
0
int wyNode::insertChild(wyNode* n, int z) {
    // insert or push
    int index = wyArrayIndexOf(m_children, n, zOrderLocator, &z);
    if(index == -1)
        wyArrayPush(m_children, n);
    else
        wyArrayInsert(m_children, n, index);

    // save z order and parent
    n->m_zOrder = z;
    n->m_parent = this;

    return index;
}
Exemple #9
0
void wyPageControl::addPage(wyNode* page) {
	// add page to array
	wyArrayPush(m_pages, page);
	page->retain();
	m_container->addChildLocked(page);
	updatePagePositions();

	// notify indicator
	if(m_indicator)
		m_indicator->onPageAdded(m_pages->num - 1);

	// ensure page position changed is set
	notifyOnPagePositionChanged();
}
Exemple #10
0
void wyBladeRibbon::update(float delta) {
	for(int i = m_dyingBlades->num - 1; i >= 0; i--) {
		// delete point in dying blade
		wyBlade* blade = (wyBlade*)wyArrayGet(m_dyingBlades, i);
		blade->deletePoint(delta);
		
		// if no point, add it to reuse queue
		if(blade->m_pointCount <= 0) {
			blade->reset();
			wyArrayPush(m_reusableBlades, blade);
			wyArrayDeleteIndex(m_dyingBlades, i);
		}
	}
	
	if(m_blade)
		m_blade->deletePoint(delta);
}
Exemple #11
0
wyBitmapFontLabel::wyBitmapFontLabel(wyBitmapFont* font, const char* text) :
        m_font(font),
        m_color(wyc4bWhite),
        m_text(NULL),
        m_spaceWidth(DP(6)),
        m_tabSize(4),
        m_alignment(LEFT),
        m_lineSpacing(0),
        m_lineHeight(font->getLineHeight()),
        m_lineWidth(MAX_FLOAT) {
	// create atlas for every page
    m_atlasList = wyArrayNew(m_font->m_textures->num);
    for(int i = 0; i < m_font->m_textures->num; i++) {
    	wyArrayPush(m_atlasList, WYNEW wyTextureAtlas(m_font->getTexture(i)));
    }

    // set text and it will trigger updateContentSize
    setText(text);
}
Exemple #12
0
wyTMXTileMap* wyTMXTileMap::make(int resId, wyTexture2D** tex, int texCount) {
	wyTMXTileMap* tmx = WYNEW wyTMXTileMap();

	// load tmx file
	wyMapInfo* map = wyTMXLoader::load(resId);

	// collect textures
	wyArray* textures = wyArrayNew(texCount);
    for(int i = 0; i < texCount; i++) {
    	wyArrayPush(textures, *(tex + i));
    }

    // init
    tmx->init(map, textures);

    // destroy temp list
    wyArrayDestroy(textures);

	return (wyTMXTileMap*)tmx->autoRelease();
}
Exemple #13
0
wyAuroraSprite* wyAuroraSprite::make(const char* path, bool isFile, int animIndex, wyTexture2D** tex, int count) {
	// create aurora sprite
	wyAuroraSprite* sprite = WYNEW wyAuroraSprite();

	// load anu file data
	sprite->m_aurora = wyAuroraManager::getInstance()->load(path, isFile);
	sprite->m_aurora->retain();

	// add others
	for(int i = 0; i < count; i++) {
		wySpriteBatchNode* sheet = wySpriteBatchNode::make(tex[i]);
		wyArrayPush(sprite->m_sheetList, sheet);
		sheet->retain();
	}

	// start animation
	sprite->playAnimation(animIndex);

	// return
	sprite->autoRelease();
	return sprite;
}
Exemple #14
0
void wyNode::scheduleLocked(wyTimer* t) {
    if(t == NULL) {
        LOGW("node schedule: timer must be non-null");
        return;
    }

    // check array
    if(m_timers == NULL)
        m_timers = wyArrayNew(3);

    // if already contains, return
    if(wyArrayIndexOf(m_timers, t, wyTimerEquals, NULL) >= 0) {
        if(t->isOneShot() && t->isDone()) {
            t->reset();

            // if node is running, schedule it now because onEnter won't be called later
            if(m_running) {
                gScheduler->scheduleLocked(t);
            }
        } else {
            LOGW("this timer is already scheduled");
        }

        return;
    }

    // if node is running, schedule it now because onEnter won't be called later
    if(m_running) {
        gScheduler->scheduleLocked(t);
    }

    pthread_mutex_lock(&gMutex);
    wyArrayPush(m_timers, t);
    wyObjectRetain(t);
    pthread_mutex_unlock(&gMutex);
}
void wyCombineColorFilter::addFilter(wyColorFilter* filter) {
	if(filter) {
		wyArrayPush(m_filters, filter);
		filter->retain();
	}
}
Exemple #16
0
void wyDirector::addLifecycleListener(const wyDirectorLifecycleListener* l, void* data) {
	wyArrayPush(m_lifecycleListeners, (void*)l);
	m_lifecycleData = data;
}
Exemple #17
0
void wyB2BodyMeta::addFixtureDef(b2FixtureDef* def) {
    wyArrayPush(m_arrayFixturedef, def);
}
Exemple #18
0
void wyAStarTile::pushChild(wyAStarTile* tile) {
    wyArrayPush(m_childs, tile);
}