Breakout tutorial on iPhone
by Andrew Poquette · in iTorque 2D · 04/21/2010 (9:02 pm) · 27 replies
Hello all! I'm trying to convert the Breakout tutorial(Part 1) to the iPhone, and I can't seem to get the ship to move when clicked. I have double checked that everything in TGB is set correctly, and it is.
Here is my code in game.cs:
The image map for the base is set to Class: baseClass, and Name: theBase
I finally figured out how to get the images to show up (by copying the image map from the managed file) but I can't seem to get this to work. I've been researching and trying all night, but any help is much appreciated.
Thanks,
~Andy
Here is my code in game.cs:
function sceneWindow2D::onMouseMove(%this, %modifier, %worldPosition, %mouseClicks){
movePaddle(%worldPosition);
}
function sceneWindow2D::onMouseDragged(%this, %modifier, %worldPosition, %mouseClicks){
movePaddle(%worldPosition);
}
function movePaddle(%worldPosition) {
%newXPos = getWord(%worldPosition,0);
if (%newXPos < 0) { %posmod= -1; } else { %posmod = 1; }
if (mAbs(%newXPos) > 65) %newXPos = %posmod * 65;
$theBase.setImpulseForce((%newXPos)*$vmod,0);
sceneWindow2D.setMousePosition("0 0");
}The image map for the base is set to Class: baseClass, and Name: theBase
I finally figured out how to get the images to show up (by copying the image map from the managed file) but I can't seem to get this to work. I've been researching and trying all night, but any help is much appreciated.
Thanks,
~Andy
About the author
#22
You can email me the source zip file and I will host it on my webserver. I will email you the link when I have it online.
05/02/2010 (7:23 am)
MarkYou can email me the source zip file and I will host it on my webserver. I will email you the link when I have it online.
#23
I've emailed my code. I've also included a ReadMe.txt file, which explains some of the changes that I made, and why I made them. I only made a few small changes though, so it's still very much like the original.
Hopefully the code will be useful.
Thanks,
Mark
05/03/2010 (4:33 pm)
Hi Dean,I've emailed my code. I've also included a ReadMe.txt file, which explains some of the changes that I made, and why I made them. I only made a few small changes though, so it's still very much like the original.
Hopefully the code will be useful.
Thanks,
Mark
#24
Hopefully I have time tonight to digest and see what I'm doing wrong.
05/04/2010 (5:29 am)
Thank you Mark and Dean for helping out tremendously with n00bs like me.Hopefully I have time tonight to digest and see what I'm doing wrong.
#25
05/05/2010 (1:30 pm)
You can download the file ---> www.deanparker.com/BreakoutTutorial_IphonePort.zip
#26
My question is:
Can you use the touch controls without having to create the sliderPadClass? Can you just use baseClass and call movePaddle(%worldposition)?
05/05/2010 (6:21 pm)
Got the file. Everything works, thanks Mark and Dean.My question is:
Can you use the touch controls without having to create the sliderPadClass? Can you just use baseClass and call movePaddle(%worldposition)?
#27
05/05/2010 (7:15 pm)
Yes, you can do that. Actually that was what I tried first, but the problem I found is that if the touch area is too small it makes it difficult to drag the object, because the finger keeps sliding outside of the touch area. I added the touchpad so that you can easily drag the base around without needing to be so precise with the finger position.
Torque Owner Mark Davies
I'm using all of the original graphics and particle effects, and it runs great.
I was hoping to write a tutorial, but hopefully the source code will be a good help to everyone new to iTGB. Where do I up load it to?