예제 #1
0
bool MainScene::init()
{
	if ( !Layer::init() )
    {
        return false;
    }


	_size = Director::getInstance()->getWinSize();
	_xPosition = 0;
	_xMoved = 0;

	_touchListener = EventListenerTouchOneByOne::create();
	_touchListener->onTouchBegan = CC_CALLBACK_2(MainScene::touchBegan,this);
	_touchListener->onTouchMoved = CC_CALLBACK_2(MainScene::touchMoved, this);
	_touchListener->onTouchEnded = CC_CALLBACK_2(MainScene::touchEnded,this);
	getEventDispatcher()->addEventListenerWithFixedPriority(_touchListener, 100);

	addScreen(1, new MainScreen);
	addScreen(2, new MainScreen);

	_fon = Sprite::create("img/ScreenFon.png");
	_fon->setScaleX(_size.width/_fon->getContentSize().width);
	_fon->setScaleY(_size.height/_fon->getContentSize().height);
	_fon->setPosition(Point(_size.width/2, _size.height/2));
	this->addChild(_fon,0);

	_menu = new MenuView;
	_menu->initialization(this);


	TextFieldTTF * tf = TextFieldTTF::textFieldWithPlaceHolder("click for input",
        "fonts/menuFont.otf",
        26);
	tf->setPosition(Point(300,300));
	this->addChild(tf, 10);
	tf->attachWithIME();

	//this->schedule(schedule_selector(MainScene::update),0.05f);

	return true;
}
예제 #2
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemImage *closeItem = MenuItemImage::create(
                                        "button.png",
                                        "button.png",
                                        CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Point(981 ,720-288));

    // create menu, it's an autorelease object
    Menu* menu = Menu::create(closeItem, NULL);
    menu->setPosition(Point::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    TextFieldTTF* label = TextFieldTTF::textFieldWithPlaceHolder("Username", "Arial Black", 25);

	//label->attachWithIME();
    
    // position the label on the center of the screen
    label->setPosition(Point(874,720-164));

    // add the label as a child to this layer
    this->addChild(label, 1);

	this->username=label;

	label = TextFieldTTF::textFieldWithPlaceHolder("Host Address", "Arial Black", 25);

	//label->attachWithIME();
    
    // position the label on the center of the screen
    label->setPosition(Point(874,720-229));

    // add the label as a child to this layer
    this->addChild(label, 2);

	this->sockaddr=label;

    // add "HelloWorld" splash screen"
    Sprite* sprite = Sprite::create("login.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("Raujika-Pastoral.mp3", true);

	this->setTouchEnabled(true);

	/*CCSprite *player = CCSprite::create("cards.png", 
                                   CCRectMake(5, 5, 75, 104) );
    player->setPosition( Point(100,100 ));
	this->addChild(player);*/

	//while(1);
    
    return true;
}