@@ -35,10 +35,44 @@ bool Bug350Layer::init()
35
35
{
36
36
if (BugsTestBase::init ())
37
37
{
38
- auto size = Director::getInstance ()->getWinSize ();
39
- auto background = Sprite::create (" Hello.png" );
40
- background->setPosition (size.width / 2 , size.height / 2 );
41
- addChild (background);
38
+ // auto size = Director::getInstance()->getWinSize();
39
+ // auto background = Sprite::create("Hello.png");
40
+ // background->setPosition(size.width / 2, size.height / 2);
41
+ // addChild(background);
42
+
43
+ auto visibleSize = Director::getInstance ()->getVisibleSize ();
44
+ Vec2 origin = Director::getInstance ()->getVisibleOrigin ();
45
+
46
+ // https: // rezghob.com/different-sprite-types/
47
+
48
+ auto spriteCache = SpriteFrameCache::getInstance ();
49
+ // spriteCache->addSpriteFramesWithFile("sprites_quad.plist");
50
+ spriteCache->addSpriteFramesWithFile (" sprites_poly.plist" );
51
+
52
+ for (int i = 0 ; i < 10000 ; i++)
53
+ {
54
+ auto sprite1 = Sprite::createWithSpriteFrameName (" PolySprite1.png" );
55
+ // sprite1->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
56
+ sprite1->setPosition (50 *AXRANDOM_MINUS1_1 () + origin.x + visibleSize.width / 2 ,
57
+ 50 *AXRANDOM_MINUS1_1 () + origin.y + visibleSize.height / 2 );
58
+ sprite1->setScale (5 );
59
+ sprite1->setColor (Color3B::RED);
60
+ this ->addChild (sprite1);
61
+
62
+ auto sprite2 = Sprite::createWithSpriteFrameName (" PolySprite2.png" );
63
+ sprite2->setPosition (origin.x + visibleSize.width / 4 , origin.y + visibleSize.height / 2 );
64
+ sprite2->setScale (5 );
65
+ sprite2->setTexture (sprite1->getTexture ());
66
+ // sprite2->setColor(Color3B::BLUE);
67
+ this ->addChild (sprite2);
68
+
69
+ auto sprite3 = Sprite::createWithSpriteFrameName (" PolySprite3.png" );
70
+ sprite3->setPosition (origin.x + visibleSize.width / 1.3 , origin.y + visibleSize.height / 2 );
71
+ sprite3->setScale (5 );
72
+ sprite3->setColor (Color3B::BLUE);
73
+ this ->addChild (sprite3);
74
+ }
75
+
42
76
return true ;
43
77
}
44
78
0 commit comments