private void performanceScale(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; pSprite.Position = new CCPoint((Random.Next() % (int)size.Width), (Random.Next() % (int)size.Height)); pSprite.Scale = Random.Float_0_1() * 100 / 50; }
public void altertime(float dt) { var action1 = (CCSpeed)(m_grossini.GetActionByTag(EaseTest.kTagAction1)); var action2 = (CCSpeed)(m_tamara.GetActionByTag(EaseTest.kTagAction1)); var action3 = (CCSpeed)(m_kathia.GetActionByTag(EaseTest.kTagAction1)); action1.Speed = Random.Float_0_1() * 2; action2.Speed = Random.Float_0_1() * 2; action3.Speed = Random.Float_0_1() * 2; }
private void performanceout20(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; if (Random.Float_0_1() < 0.2f) { pSprite.Position = new CCPoint((Random.Next() % (int)size.Width), (Random.Next() % (int)size.Height)); } else { pSprite.Position = new CCPoint(-1000, -1000); } }
public void addNewSpriteAtPosition(CCPoint p) { CCLog.Log("Add sprite #{2} : {0} x {1}", p.X, p.Y, _batch.ChildrenCount + 1); //We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is //just randomly picking one of the images int idx = (Random.Float_0_1() > .5 ? 0 : 1); int idy = (Random.Float_0_1() > .5 ? 0 : 1); var sprite = new CCPhysicsSprite(m_pSpriteTexture, new CCRect(32 * idx, 32 * idy, 32, 32)); _batch.AddChild(sprite, 0, kTagForPhysicsSprite); sprite.Position = new CCPoint(p.X, p.Y); // Define the dynamic body. //Set up a 1m squared box in the physics world b2BodyDef def = b2BodyDef.Create(); def.position = new b2Vec2(p.X / PTM_RATIO, p.Y / PTM_RATIO); def.type = b2BodyType.b2_dynamicBody; b2Body body = _world.CreateBody(def); // Define another box shape for our dynamic body. var dynamicBox = new b2PolygonShape(); dynamicBox.SetAsBox(.5f, .5f); //These are mid points for our 1m box // Define the dynamic body fixture. b2FixtureDef fd = b2FixtureDef.Create(); fd.shape = dynamicBox; fd.density = 1f; fd.friction = 0.3f; b2Fixture fixture = body.CreateFixture(fd); sprite.PhysicsBody = body; //_world.SetContactListener(new Myb2Listener()); // _world.Dump(); }