Exemplo n.º 1
0
wyMotionStreak::wyMotionStreak(float fade, wyTexture2D* tex, wyColor4B color, wyMotionStreakStyle style) :
		m_segThreshold(3),
		m_lastLocation(wyp(-1, -1)),
		m_currentLocation(wyp(-1, -1)),
		m_paused(false) {
	// init member
	m_pendingPoints = WYNEW vector<PendingPoint>();
	m_pendingPoints->reserve(10);

	// create ribbon by style
	switch(style) {
		case MS_STYLE_STRIP:
			m_ribbon = wyStripRibbon::make(tex, color, fade);
			break;
		case MS_STYLE_SPOT:
			m_ribbon = wySpotRibbon::make(tex, color, fade);
			break;
		case MS_STYLE_BLADE:
			m_ribbon = wyBladeRibbon::make(tex, color, fade);
			break;
		case MS_STYLE_LINE:
			m_ribbon = wyLineRibbon::make(tex, color);
			break;
	}

	// add ribbon to motion streak
    addChildLocked(m_ribbon);

    // update ribbon position
    wyTargetSelector* ts = wyTargetSelector::make(this, SEL(wyMotionStreak::update));
    wyTimer* timer = wyTimer::make(ts);
    scheduleLocked(timer);
}
Exemplo n.º 2
0
	void startUpdateWorld() {
		wyTargetSelector* ts = new wyTargetSelector(this, TS_UPDATE, NULL);
		wyTimer* t = new wyTimer(ts);
		scheduleLocked(t);
		t->release();
		ts->release();
	}
Exemplo n.º 3
0
wyScrollableLayer::wyScrollableLayer(wyColor4B color) :
		wyColorLayer(color),
		m_vertical(false),
		m_horizontal(false),
		m_scrolling(false),
		m_flinging(false),
		m_childTouchCancelled(false),
		m_lastX(0),
		m_lastY(0),
		m_firstX(0),
		m_firstY(0),
		m_leftMargin(0),
		m_rightMargin(0),
		m_topMargin(0),
		m_bottomMargin(0),
		m_leftBorder(0),
		m_rightBorder(0),
		m_topBorder(0),
		m_bottomBorder(0),
		m_xExtent(0),
		m_yExtent(0),
		m_horizontalThumb(NULL),
		m_verticalThumb(NULL),
		m_fadeOutTime(0),
		m_noScrollTime(0),
		m_fadeingOut(false),
		m_callback(NULL),
#if ANDROID
		m_jCallback(NULL),
#endif
		m_scroller(WYNEW wyScroller()) {
	// enable event
	setTouchEnabled(true);
	setGestureEnabled(true);

	// create container
	m_container = wyScrollContainer::make();
	addChildLocked(m_container);

	// schedule fling timer
	wyTargetSelector* ts = wyTargetSelector::make(this, SEL(wyScrollableLayer::updateFling));
	wyTimer* timer = wyTimer::make(ts);
	scheduleLocked(timer);
}
Exemplo n.º 4
0
wyPageControl::wyPageControl() :
		m_pages(wyArrayNew(5)),
		m_container(NULL),
		m_lastX(0),
		m_lastY(0),
		m_scroller(WYNEW wyScroller()),
		m_flinging(false),
		m_scrolling(false),
		m_vertical(false),
		m_initialPageIndex(-1),
		m_indicator(NULL),
		m_data(NULL),
#if ANDROID
		m_jCallback(NULL),
#endif
		m_centerY(-1),
		m_centerX(-1) {
	// set page control properties
	setRelativeAnchorPoint(false);
	setContentSize(wyDevice::winWidth, wyDevice::winHeight);
	memset(&m_callback, 0, sizeof(wyPageControlCallback));

	// create container
	m_container = WYNEW wyLayer();
	m_container->setPosition(0, 0);
	addChildLocked(m_container);
	m_container->release();

	// enable events
	setTouchEnabled(true);
			
	// schedule fling timer
	wyTargetSelector* ts = wyTargetSelector::make(this, SEL(wyPageControl::updateFling));
	wyTimer* timer = wyTimer::make(ts);
	scheduleLocked(timer);
}