|
Very interesting but this forum is really not the place; you should write an article about it and publish it that way.
|
|
|
|
|
sorry for putting it in the wrong area im am kind of new to this site was not sure where to put it. I look at making this a article instead and remove it from the forums.
|
|
|
|
|
Steven Richardson wrote: im am kind of new to this site was not sure Always worth looking at the Readmes, Howtos and FAQs first.
|
|
|
|
|
I created a article on this topic I am unable to remove the thread if possible could you remove it.
|
|
|
|
|
The thread is permanent now; don't worry about it.
|
|
|
|
|
hi there i have a problem with my 2d character again...i fixed my previous problems but the new problem is that,that i cant make my character punchin...he walks,he jumps pretty well but i'm in some problem with punchin movement or anything like this...i made a punch animation and i made a transation to the idle and from idle to puch in the animator window...and also i made a trigger parameter but my code dosent work...may be the code i wrote is completley worng...if thats wrong please tell me what shout id do? thanks
using UnityEngine;
using System.Collections;
public class ScrorpionControllerScript : MonoBehaviour
{
public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;
bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
float jumpTime, jumpDelay = 0.2f;
bool jumped;
float punchTime, punchDelay = .5f;
bool punch;
void Start ()
{
anim = GetComponent<Animator> ();
}
void FixedUpdate ()
{
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
anim.SetBool ("Ground", grounded);
anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);
anim.SetBool ("Ground", grounded);
float move = Input.GetAxis ("Horizontal");
anim.SetFloat ("wa", Mathf.Abs (move));
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D.velocity.y);
if(move > 0 &&! facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Update()
{
if(Input.GetKeyDown (KeyCode.Space) && grounded)
{
rigidbody2D.AddForce(transform.up * 275f);
jumpTime = jumpDelay;
anim.SetTrigger("Jump");
jumped = true;
}
jumpTime -= Time.deltaTime;
if (jumpTime <= 0 && grounded && jumped)
{
anim.SetTrigger ("Land");
jumped = false;
}
if (Input.GetKeyDown (KeyCode.R));
{
punchTime = punchDelay;
anim.SetTrigger("punch");
punch = true;
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
|
|
|
|
|
You posted the same thing 7 hours ago in QA: unity 2D C# coding problem[^] and were told you didn't ask an actual question.
Please don't post the same thing in multiple places: it duplicates work and that annoys people.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
When I have the following definitions:
public class CMsg
{
protected int m_Id;
}
public class CMsgTx : CMsg
{
public string m_Dst;
}
To be used by:
public abstract class CNet
{
abstract public int SendMsg(ref CMsg oMsg);
}
public class CNetSend : CNet
{
override public int SendMsg(ref CMsg oMsg)
{
CMsgTx oTxMsg = oMsg as CMsgTx;
return 1;
}
}
I getting compiler error when trying to call SendMsg:
{...
CMsgTx oMsg = new CMsgTx();
CNetSend oSender = new CNetSend()
oSender.SendMsg(ref oMsg);
...}
My question is how to convert CMsgTx.oMsg to CMsg when calling SendMsg,
I thought that the compiler would do it...
|
|
|
|
|
You can't do that with ref parameters.
Why not? Simple: you could replace the instance you pass in with a completely different type also derived from the same base type - which could mean that the outside world ends up with a CMsgTx variable referencing a CMsgBananaSplit instance - which doesn't support half the properties of CMsgTx, but does support the IceCream property and the GetNuts method - and so forth.
You can only pass a reference through if it is of the exact same type as the methdo declaration, not a derived type at all.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
What about out parameters,
in case of:
public abstract class CNet
{
abstract public int SendMsg(out CMsg oMsg);
}
public class CNetRx : CNet
{
override public int SendMsg(out CMsg oMsg)
{
CMsgTx oTxMsg = new CMsgTx();
oMsg = (CMsg)oTxMsg ;
return 1;
}
}
and the program:
CMsg oM;
CNetRx oNetRx = new CNetRx();
oNetRx.SendMsg(out oM);
CMsgTx oMsgTx = oM as CMsgTx;
is there also loss of information?
Do you suggest other 'design' for CNet and CMsg classes?
|
|
|
|
|
No - because what you pass through is a valid CMsg - it's derived from it, and the variable you pass into is a CMsg, not a derived class. So to use it as an instance of CMsgTx you have to cast it - as your code does - and a derived class instance that doesn't include CMsgTx will not cast: the as will return null.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Why does it need to be a ref parameter?
namespace ConsoleApplication379
{
class ReferenceTest
{
public string Bla { get; set; }
}
class Program
{
static void Main(string[] args)
{
var a = new ReferenceTest() { Bla = "Test" };
change(a);
Console.WriteLine(a.Bla);
Console.ReadLine();
}
static void change(ReferenceTest whichOne)
{
whichOne.Bla = "Hello World";
}
}
} I'm asking because it makes more sense to use on a value-type, not on a pointer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Why MVC best from Asp.Net while less work in asp.net as compare to MVC.
|
|
|
|
|
Did you read your question before posting? It's a good practice...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Sorry , I got answer of my question.
|
|
|
|
|
It depends what you are doing - to hack together a simple ASP.NET winforms style web app, then asp.net is probably going to be easier. Where MVC wins is where you actually want to create websites, or sites with more modern features (for example AJAX calls, exposing a REST API), then MVC3 wins IMO.
The other thing you have to take into account is the learning curve: if you've been an asp.net "forms" developer for 2 years and you switch to MVC, then you're already 2-years behind more or less, and you have to stop using a lot of techniques you've become used to.
So the answer is, if you've gained a similar amount of experience/expertise in both technologies and one has taken more effort than the other one, you've chosen the wrong tech.
|
|
|
|
|
Thanks a lot ,
|
|
|
|
|
What is Extension Method in C# and when i can use it ?
|
|
|
|
|
|
An extension method is a piece of code that allows you to extend a type with custom functionality. This feature was introduced alongside LINQ. Suppose you wanted to add the ability to check whether or not an integer was within a certain range, you would declare a static method inside a static class (this is required for extension methods), that passed in the parameter in a special way. Here's this example
public static class IntegerExtensions
{
public static bool Between(this int value, int startRange, int endRange)
{
return value >= startRange && value <= endRange;
}
} To call this you would do something like this:
int checker = 10;
if (checker.Between(0, 50)
{
Console.WriteLine("I'm in the range");
} Now, if you want to use the extension method, you have to make sure that the namespace for the static class is included in the file that you are calling the extension from. Also, there's nothing to stop you writing this code as well
if (IntegerExtensions.Between(checker, 0, 50)) Ultimately they resolve to the same thing.
|
|
|
|
|
What sort of pond life would downvote such an excellent answer to a question? Compensation provided.
|
|
|
|
|
Thanks. I have to admit, I was surprised by the vote as I thought I'd given a clear enough start to get someone on the way with extension methods. Oh well
|
|
|
|
|
Hi
I have about 1000 2d points that I draw a ClosedCurve on bitmap then on picturbox, but I want saving a few points from this 1000 points that are necessery to drawing previous ClosedCurve or shape.
Thanks
|
|
|
|
|
What have you tried, where exactly are you stuck?
What do you mean when you say saving? When will you draw that previous ClosedCurve? When the application restarts? When the user hits the undo button? On the whim of a butterfly flapping its wings ?
Give us more info, so we better understand the question.
|
|
|
|
|
thanks, suppose we have an image that contain a shape like "s", this "s" formed from thousands points or pixels. well, we want drawing a shape like "s" whit .DrawCurve method in C# but we don't want .DrawCurve accept that thousnds parameter(or points). we want detect a few number of point that are critical(in mathemathics) or necessary points then draw same shape("s"). of course if we detect this points we can use DrawLine or DrawBezier and etc methods to draw same shape("s").
|
|
|
|