本文整理汇总了C#中CCPoint类的典型用法代码示例。如果您正苦于以下问题:C# CCPoint类的具体用法?C# CCPoint怎么用?C# CCPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCPoint类属于命名空间,在下文中一共展示了CCPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddedToScene
protected override void AddedToScene()
{
base.AddedToScene();
// Use the bounds to layout the positioning of our drawable assets
var bounds = VisibleBoundsWorldspace;
// position the label on the center of the screen
label.Position = bounds.LowerLeft;
//Ubicar las 6 sillas al inicio
//TODO hallar el centro de la pantalla
CCSize tamaño = Scene.Window.WindowSizeInPixels;
CCPoint centro = tamaño.Center;
double cx = centro.X;
double cy = centro.Y;
double radio = 200;
for (int i = 0; i < sillas.Count; i++)
{
double xpos = cx + radio * Math.Sin(2 * Math.PI / 6 * i);
double ypos = cy + radio * Math.Cos(2 * Math.PI / 6 * i);
CCPoint position = new CCPoint((float)xpos, (float)ypos);
sillas[i].Position = position;
sillas[i].Rotation = (float)(180 + 360 / 6 * i);
}
// Register for touch events
var touchListener = new CCEventListenerTouchAllAtOnce();
touchListener.OnTouchesEnded = OnTouchesEnded;
AddEventListener(touchListener, this);
}
示例2: CCRipple3D
public CCRipple3D (float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude)
: base (duration, gridSize, amplitude)
{
Position = position;
Radius = radius;
Waves = waves;
}
示例3: ProjectVelocityOnSurface
protected void ProjectVelocityOnSurface(CCPoint reposition)
{
if (reposition.X != 0 || reposition.Y != 0)
{
var repositionNormalized = reposition;
//vector归一化
repositionNormalized.Normalize ();
CCPoint velocity = new CCPoint (VelocityX, VelocityY);
//计算velocity和repositionNormalized的点积,得到瓦片位移向量作用后的位置
var dot = CCPoint.Dot (velocity, repositionNormalized);
// falling into the collision, rather than out of
//如果dot小于0,则entity掉入瓦片中(掉入被撞击的物体中)
//掉入是正常现象
//之后把entity的速度更改下
//如果是在地面,速度会被改为0
//不太懂这个算法
if (dot < 0)
{
velocity -= repositionNormalized * dot;
VelocityX = velocity.X;
VelocityY = velocity.Y;
}
}
}
示例4: CCLens3D
public CCLens3D (float duration, CCGridSize gridSize, CCPoint position, float radius) : base (duration, gridSize)
{
Position = position;
Radius = radius;
LensScale = 0.7f;
Concave = false;
}
示例5: UpdateBallTransform
public void UpdateBallTransform()
{
if (PhysicsBody != null)
{
b2Vec2 pos = PhysicsBody.Position;
float x = pos.x * ptmRatio;
float y = pos.y * ptmRatio;
if (IgnoreAnchorPointForPosition)
{
x += AnchorPointInPoints.X;
y += AnchorPointInPoints.Y;
}
// Make matrix
float radians = PhysicsBody.Angle;
var c = (float)Math.Cos (radians);
var s = (float)Math.Sin (radians);
if (!AnchorPointInPoints.Equals (CCPoint.Zero))
{
x += c * -AnchorPointInPoints.X + -s * -AnchorPointInPoints.Y;
y += s * -AnchorPointInPoints.X + c * -AnchorPointInPoints.Y;
}
Position = new CCPoint(x, y);
}
}
示例6: actionWithDuration
/** creates the action */
public static CCMoveTo actionWithDuration(float duration, CCPoint position)
{
CCMoveTo moveTo = new CCMoveTo();
moveTo.initWithDuration(duration, position);
return moveTo;
}
示例7: AddNewSpriteWithCoords
void AddNewSpriteWithCoords(CCPoint p)
{
CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);
int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
int x = (idx % 5) * 85;
int y = (idx / 5) * 121;
CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
sprite.Position = (new CCPoint(p.X, p.Y));
BatchNode.AddChild(sprite);
CCFiniteTimeAction action = null;
float random = (float)CCRandom.NextDouble();
if (random < 0.20)
action = new CCScaleBy(3, 2);
else if (random < 0.40)
action = new CCRotateBy (3, 360);
else if (random < 0.60)
action = new CCBlink (1, 3);
else if (random < 0.8)
action = new CCTintBy (2, 0, -255, -255);
else
action = new CCFadeOut (2);
CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));
sprite.RunAction(new CCRepeatForever (seq));
}
示例8: DistanceTo
public float DistanceTo(ref CCPoint vector, out Segment connectingSegment)
{
float segmentLength = (float)this.GetLength();
CCPoint normalizedLine = new CCPoint(
(float)(Point2.X - Point1.X) / segmentLength,
(float)(Point2.Y - Point1.Y) / segmentLength);
CCPoint pointVector = new CCPoint((float)(vector.X - Point1.X), (float)(vector.Y - Point1.Y));
float length = CCPoint.Dot(pointVector, normalizedLine);
connectingSegment = new Segment ();
if (length < 0)
{
connectingSegment.Point1 = vector;
connectingSegment.Point2 = Point1;
return (float) connectingSegment.GetLength();
}
else if (length > segmentLength)
{
connectingSegment.Point1 = vector;
connectingSegment.Point2 = Point2;
return (float) connectingSegment.GetLength();
}
else
{
connectingSegment.Point1 = vector;
connectingSegment.Point2 = new CCPoint(Point1.X + length * normalizedLine.X,
Point1.Y + length * normalizedLine.Y);
return (float)connectingSegment.GetLength();
}
}
示例9: JumpPad
public JumpPad(b2Vec2 JumpImpuls, CCPoint Position, b2World gameWorld)
{
this.Texture = new CCTexture2D ("jumppad");
this.Scale = SpriteScale;
this.Position = Position;
this.IsAntialiased = false;
jumpImpuls = JumpImpuls;
totalJumps = 0;
//box2d
b2BodyDef jumpPadDef = new b2BodyDef ();
jumpPadDef.type = b2BodyType.b2_kinematicBody;
jumpPadDef.position = new b2Vec2 ((Position.X + this.ScaledContentSize.Width/2)/PhysicsHandler.pixelPerMeter, (Position.Y + this.ScaledContentSize.Height/4) / PhysicsHandler.pixelPerMeter);
JumpPadBody = gameWorld.CreateBody (jumpPadDef);
b2PolygonShape jumpPadShape = new b2PolygonShape ();
jumpPadShape.SetAsBox ((float)this.ScaledContentSize.Width / PhysicsHandler.pixelPerMeter / 2, (float)this.ScaledContentSize.Height / PhysicsHandler.pixelPerMeter / 4);// /4 weil die hitbox nur die hälfte der textur ist
b2FixtureDef jumpPadFixture = new b2FixtureDef ();
jumpPadFixture.shape = jumpPadShape;
jumpPadFixture.density = 0.0f; //Dichte
jumpPadFixture.restitution = 0f; //Rückprall
jumpPadFixture.friction = 0f;
jumpPadFixture.userData = WorldFixtureData.jumppad;
JumpPadBody.CreateFixture (jumpPadFixture);
//
}
示例10: RubeBasicLayer
public RubeBasicLayer(string jsonfile)
{
AnchorPoint = new CCPoint(0, 0);
HasWheel = true;
JSON_FILE = jsonfile;
TouchPanel.EnabledGestures = GestureType.Pinch | GestureType.PinchComplete;
var touchListener = new CCEventListenerTouchAllAtOnce();
touchListener.OnTouchesBegan = OnTouchesBegan;
touchListener.OnTouchesMoved = OnTouchesMoved;
touchListener.OnTouchesEnded = OnTouchesEnded;
touchListener.OnTouchesCancelled = OnTouchesCancelled;
AddEventListener(touchListener, this);
var mouseListener = new CCEventListenerMouse();
mouseListener.OnMouseScroll = OnMouseScroll;
AddEventListener(mouseListener, this);
// set the starting scale and offset values from the subclass
Position = InitialWorldOffset();
Scale = InitialWorldScale();
// load the world from RUBE .json file (this will also call afterLoadProcessing)
LoadWorld();
}
示例11: better
bool enemyCantBeDamagedForShortInterval; // after damage occurs the enemy gets a moment of un-damage-abilty, which should play better ( I think)
public Enemy(b2World world,
CCPoint location,
string spriteFileName,
bool isTheRotationFixed,
bool getsDamageFromGround,
bool doesGetDamageFromDamageEnabledStackObjects,
int breaksFromHowMuchContact,
bool hasDifferentSpritesForDamage,
int numberOfFramesToAnimateOnBreak,
float density,
CreationMethod createHow,
int points,
BreakEffect simpleScoreVisualFXType)
{
InitWithWorld(world,
location,
spriteFileName,
isTheRotationFixed,
getsDamageFromGround,
doesGetDamageFromDamageEnabledStackObjects,
breaksFromHowMuchContact,
hasDifferentSpritesForDamage,
numberOfFramesToAnimateOnBreak,
density,
createHow,
points,
simpleScoreVisualFXType);
}
示例12: DrawSolidCircle
public override void DrawSolidCircle(Box2D.Common.b2Vec2 center, float radius, Box2D.Common.b2Vec2 axis, Box2D.Common.b2Color color)
{
CCPoint centerToPoint = new CCPoint (center.x * 50f, center.y * 50f);
//CCColor4B Color = new CCColor4B (color.r, color.g, color.b, 255);
DrawNode.DrawCircle (centerToPoint, radius, CollusionColor);
}
示例13: GameMenu
public GameMenu()
{
var screenSize = Director.WindowSizeInPixels;
voiceButtonName = "VoiceFX";
voiceButtonNameDim = "VoiceFX";
soundButtonName = "SoundFX";
soundButtonNameDim = "SoundFX";
ambientButtonName = "AmbientFX";
ambientButtonNameDim = "AmbientFX";
SoundFXMenuLocation = new CCPoint(110, 55);
VoiceFXMenuLocation = new CCPoint(230, 55);
AmbientFXMenuLocation = new CCPoint(355, 55);
// TouchEnabled = true;
IsSoundFXMenuItemActive = !GameData.SharedData.AreSoundFXMuted;
IsVoiceFXMenuActive = !GameData.SharedData.AreVoiceFXMuted;
IsAmbientFXMenuActive = !GameData.SharedData.AreAmbientFXMuted;
}
示例14: Update
public override void Update(float time)
{
if (m_pTarget != null)
{
// Is % equal to fmodf()???
float frac = (time * m_nJumps) % 1f;
float y = m_height * 4f * frac * (1f - frac);
y += m_delta.Y * time;
float x = m_delta.X * time;
#if CC_ENABLE_STACKABLE_ACTIONS
CCPoint currentPos = m_pTarget.Position;
CCPoint diff = currentPos - m_previousPos;
m_startPosition = diff + m_startPosition;
CCPoint newPos = m_startPosition + new CCPoint(x,y);
m_pTarget.Position = newPos;
m_previousPos = newPos;
#else
m_pTarget.Position = m_startPosition + new CCPoint(x, y);
#endif
// !CC_ENABLE_STACKABLE_ACTIONS
}
}
示例15: AddNewSpriteWithCoords
void AddNewSpriteWithCoords(CCPoint p)
{
CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)this[(int)kTags.kTagSpriteBatchNode];
int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
int x = (idx % 5) * 85;
int y = (idx / 5) * 121;
CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
sprite.Position = (new CCPoint(p.X, p.Y));
BatchNode.AddChild(sprite);
CCFiniteTimeAction action = null;
var random = (float)CCRandom.NextDouble();
if (random < 0.20)
action = scaleBy;
else if (random < 0.40)
action = rotateBy;
else if (random < 0.60)
action = blink;
else if (random < 0.8)
action = tintBy;
else
action = fadeOut;
sprite.RepeatForever(action, action.Reverse());
}