Stupid S Word
by rennie moffat · in iTorque 2D · 03/25/2011 (11:57 am) · 16 replies
Hi,
I can anyone tell me why %this.posDiff is not returning an echo?
I can anyone tell me why %this.posDiff is not returning an echo?
%XPosition = getWord(%touchX, 0);
%yPosition = getWord(%touchY, 0);
%touchPos = %XPosition SPC %YPosition;
%this.posDiff = t2dVectorDistance($cloud.position, %touchPos);
echo("$cloudPos" @ $cloud.position);
echo("%touchPos" @ %touchPos);
echo("%this.posDiff" @ %this.posDiff);About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
Funny thing for me as I have never seen this before, but muy first touch down returns a letter. Could be an A, B a â«, then nothing.
:S
03/25/2011 (12:07 pm)
In the game.csfunction oniPhoneTouchDown( %touchCount, %touchX, %touchY )
{
%XPosition = getWord(%touchX, 0);
%yPosition = getWord(%touchY, 0);
%touchPos = %XPosition SPC %YPosition;
%this.posDiff = t2dVectorDistance($cloud.position, %touchPos);
echo("$cloudPos" @ $cloud.position);
echo("%touchPos" @ %touchPos);
echo("%this.posDiff" @ %this.posDiff);
}Funny thing for me as I have never seen this before, but muy first touch down returns a letter. Could be an A, B a â«, then nothing.
:S
#3
Sorry.
Thanks. GGC.
03/25/2011 (12:09 pm)
I just realized... it has no "%this" in the passed parameters.Sorry.
Thanks. GGC.
#4
Before posting on the forums it might be wise to reread your code a few times and put some real thought into the issue before immediately posting on the forums.
Not trying to discourage you from posting, but you should really try to develop those critical thinking skills.
03/25/2011 (12:18 pm)
rennieBefore posting on the forums it might be wise to reread your code a few times and put some real thought into the issue before immediately posting on the forums.
Not trying to discourage you from posting, but you should really try to develop those critical thinking skills.
#5
Things just seem to come to me when I know others are looking at it. Weird, I know but hey that's me.
Thanks.
03/25/2011 (12:19 pm)
I understand however, oddly in my case, with or with out being given an answer I usually find it upon posting. I hear but anyhow, whatever, thanks.Things just seem to come to me when I know others are looking at it. Weird, I know but hey that's me.
Thanks.
#6
If you are open to a suggestion, I can help you get to the answer before you post. It's a simple practice. Let me know if you are interested.
03/25/2011 (12:26 pm)
Quote:I understand however, oddly in my case, with or with out being given an answer I usually find it upon posting. I hear but anyhow, whatever, thanks.
If you are open to a suggestion, I can help you get to the answer before you post. It's a simple practice. Let me know if you are interested.
#7
And yes I am interested but I have one more question related to the function I am posting for...
When applying touch drag to a large object, in my case 4 times the size of the window (480x320), the way the code is now, it does not account for the offset between the objects position and the touch position. Therefore when you touch, and move, the object, in my large object case, the object jumps to the touchPos.
I have tried using vector distance but that only return a single value float. I am not sure how to make that work to account for the offset and I have also tried vector sub, but that does not necessarily work will with two negative numbers. What would be the best way to go about this?
03/25/2011 (12:31 pm)
Does it involve reading?And yes I am interested but I have one more question related to the function I am posting for...
When applying touch drag to a large object, in my case 4 times the size of the window (480x320), the way the code is now, it does not account for the offset between the objects position and the touch position. Therefore when you touch, and move, the object, in my large object case, the object jumps to the touchPos.
I have tried using vector distance but that only return a single value float. I am not sure how to make that work to account for the offset and I have also tried vector sub, but that does not necessarily work will with two negative numbers. What would be the best way to go about this?
#8
%obj.originalposition = %obj.getPosition();
on touch move calculate the difference between the current touch position and the down position.
then set the objects offset position as follows
%newPos = %obj.originalposition + %offset; // You'll have to do X and Y separately then concatenate them.
%obj.setPosition(%newPos);
keep in mind that this was pseudo code, it wont run but it will show you the logic behind how to make it work.
use getWord function. :P
03/25/2011 (12:38 pm)
Rennie - On touch down record the position of the touch.... Also set your objects original position like so:%obj.originalposition = %obj.getPosition();
on touch move calculate the difference between the current touch position and the down position.
then set the objects offset position as follows
%newPos = %obj.originalposition + %offset; // You'll have to do X and Y separately then concatenate them.
%obj.setPosition(%newPos);
keep in mind that this was pseudo code, it wont run but it will show you the logic behind how to make it work.
use getWord function. :P
#9
Thanks Chris, your explanation makes sense. I am just working out the details now.
cheers.
03/25/2011 (1:00 pm)
I thought I answered this.Thanks Chris, your explanation makes sense. I am just working out the details now.
cheers.
#10
Game programming has very little to do with game design. Game design has something to do with design. Game programming is all about problem solving. There are many ways to solve a problem, but the first step is always to identify it. You can't fix something until you identify the problem. You are excellent at doing that. Let's get to the point
Your code:
To identify a problem, you can use tools. Your tool of choice is the echo function. This works. It allows you to quickly identify your problem, which is %this.posDiff is not printing values to the console.
Time and time again, you get to this point and go to the forums first. As Chris stated, don't let anything discourage you from using the forums. However, you made a key statement which would save you some time:
You know the problem, you narrowed it down to a single function. Now just read the code. It's a pattern of your's, which means you can apply the same problem solving process in the future and increase your efficiency.
03/25/2011 (1:11 pm)
Quote:Does it involve reading?Yes. It involves reading what I'm about to say carefully and taking it to heart.
Game programming has very little to do with game design. Game design has something to do with design. Game programming is all about problem solving. There are many ways to solve a problem, but the first step is always to identify it. You can't fix something until you identify the problem. You are excellent at doing that. Let's get to the point
Your code:
function oniPhoneTouchDown( %touchCount, %touchX, %touchY )
{
%XPosition = getWord(%touchX, 0);
%yPosition = getWord(%touchY, 0);
%touchPos = %XPosition SPC %YPosition;
%this.posDiff = t2dVectorDistance($cloud.position, %touchPos);
echo("$cloudPos" @ $cloud.position);
echo("%touchPos" @ %touchPos);
echo("%this.posDiff" @ %this.posDiff);
}To identify a problem, you can use tools. Your tool of choice is the echo function. This works. It allows you to quickly identify your problem, which is %this.posDiff is not printing values to the console.
Time and time again, you get to this point and go to the forums first. As Chris stated, don't let anything discourage you from using the forums. However, you made a key statement which would save you some time:
Quote:oddly in my case, with or with out being given an answer I usually find it upon posting.It's not odd. It works this way for everyone. You had a problem, you put it out into the world and then you quickly discover the issue when someone kick starts your problem solving.
Quote:you really should post your entire functions if you want help. It's a lot easier.That's all it took. When you posted your entire function, you saw your problem immediately. To save you several minutes (sometimes hours), just look at your code one more time. Go to post, stop, then look at your code.
You know the problem, you narrowed it down to a single function. Now just read the code. It's a pattern of your's, which means you can apply the same problem solving process in the future and increase your efficiency.
#11
03/25/2011 (1:43 pm)
Haha I think he should be discouraged from posting as I motion that we take a fee from any products Rennie develops and sells in Torque =P
#12
Beyond that I am relatively speaking a beginner so I appreciate the help. If I could not vent, ask, on here I would be lost.. or on another platform, so if you like me, you'll keep me.
Haha. just playing, in all reality I do appreciate it.
03/25/2011 (2:30 pm)
I believe there is a stated "no royalty fees" in iT2D. Beyond that I am relatively speaking a beginner so I appreciate the help. If I could not vent, ask, on here I would be lost.. or on another platform, so if you like me, you'll keep me.
Haha. just playing, in all reality I do appreciate it.
#13
03/25/2011 (3:09 pm)
On a good note we are filling the forums with good searchable threads that might help others at some point! :D
#14
03/25/2011 (3:30 pm)
What Juntaou said. I usually search, search again, and then search one more time before I post a question or frustration. I would have a lot more posts in these forums if not for those made by people like Rennie.
#15
::))((((
Honestly tho I will never understand the complaints of asking. If you can help do, if not don't simple as that. I am not looking to start a debate or argument, just how I feel.
Now I have to go play with my new iPhone gesture skills.
:::)))
03/25/2011 (3:35 pm)
See. My posting helps others. In many cases I am asking what others are too scared or embarrassed to ask. I am the simple programmers best friend.::))((((
Honestly tho I will never understand the complaints of asking. If you can help do, if not don't simple as that. I am not looking to start a debate or argument, just how I feel.
Now I have to go play with my new iPhone gesture skills.
:::)))
#16
03/25/2011 (7:01 pm)
I think the concern is that the forum will be flooded with the same question over and over again. I think there's value in reasking a question that was asked a year or so ago because things may have changed so much since then that the answer is different now.
Torque Owner Chris Labombard
Premium Preferred