Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

7 years ago by cjennison

In AppMobi, I am able to test the touch events in the emulator fine - however, when testing on an iTouch, the touch events are not coming up at all.


var nX;
var nY;

var touchState = "UP";
var pressState = "NONE";


Canvas.addEventListener('touchstart', function(event){
	//ig.input.actions['mouse']=true;
	nX=event.touches[0].pageX;
	nY=event.touches[0].pageY;
	touchState = "DOWN";
	pressState = "PRESSED";
}, false);
Canvas.addEventListener('touchmove', function(event){
	//ig.input.actions['mouse']=true;
	nX=event.touches[0].pageX;
	nY=event.touches[0].pageY;  
	pressState = "NONE";
}, false);
Canvas.addEventListener('touchend', function(event){
	//ig.input.released['mouse'] = true;
	nX=event.touches[0].pageX;
	nY=event.touches[0].pageY;  
	touchState = "UP"; 
	pressState = "NONE"; 
},false);

Is there an explanation for why this would work in the emulator and not on the phone?
I am using Direct Canvas.

7 years ago by exps1

I had similar problem with testing in AppMobi XDK, works in emulator but not on device. If that's what you are using make sure the device is using the same code as is loaded in the hub. If you are not making a new release the device can/will use the application code stored in app-lab application data vs. what is loaded in the appmobl hub.

Simple test: change the start position of an entity and see if the emulator and the device show the same thing. If they are different manually clear the app.lab application data and reload the app.

In my case the code stored on the device had an error which made the entity disappear when touchstart fired. I spend hours trying to figure why touchstart wasn't working on the device.

Hope this spares others the grief.

Micah

7 years ago by cjennison

How do you create a new release? The option is greyed out.

Clearing the data, does this mean deleting the app and reuploading it?

7 years ago by TylerAppmobi

Hey guys,

Sorry for not seeing this thread until now, I have been traveling a lot this week.

@cjennison
Is there an explanation for why this would work in the emulator and not on the phone?
The emulator for DC isn't as accurate since it's hard to make the XDK act like it's contexts can't see each other and act like it is using OpenGL on desktop. We always suggest to still test on device, which will be what your app will look like when deployed.

Your touch code looks like it should work fine.

What does your code do after it gets the touch values?

How do you create a new release? The option is greyed out.
The new release button is for when we push a new version of appMobi. So if you made your game in 3.3.0 and we released 3.4.0, it'd create a new release.

Clearing the data, does this mean deleting the app and reuploading it?
If your appLab isn't displaying the correct code, you may need to just wait with it open for a couple minutes. The app plays the code base it had previously as it downloads the new code (this takes longer the bigger your bundle). After the new bundle is downloaded, it will update itself. You can delete applab and redownload to clear it's cache and just pull down your bundle if it seems to have gotten stuck.

7 years ago by cjennison

The code moves the player, but to test I have just added a font draw.

if (playerPosition < nX/this.divider + ig.game.screen.x){
	this.accel.x = accel;
}
else if (playerPosition > nX/this.divider + ig.game.screen.x){
	this.accel.x = -accel;
}
else {
	this.accel.x = 0;
}
						
//if x is between the buffers of nX/Divider
if (playerPosition > nX/this.divider+ ig.game.screen.x - 10 && playerPosition < nX/this.divider+ ig.game.screen.x + 5){
	this.accel.x = 0;
}

And then to test the touch state:
ig.game.font.draw("nX: " + nX, 10, 30);
ig.game.font.draw("nY: " + nY, 10, 40);

nX comes up as Undefined and nY comes up as NaN.

-- Also
Sometimes, when I push a build ot Test Anywhere, the game seems to go crazy, speeding up drastically and crashing the game, I have to reload the app to get it to stop. After about 2 reloads, I get the Update prompt.

7 years ago by TylerAppmobi

If you contact my at tyler@appmobi.com and leave your email address associated with your appMobi account (and consent to me looking at your code), I can take a look into your game and let you know what's happening with the touches. It's hard to debug touches through snippets.

How long have you been experiencing this update bug in the XDK?

7 years ago by cjennison

I have been experiencing this for the last week. Actually, all of my game's touch events have all failed.

I will send you an e-mail from my AppMobi account.

7 years ago by DavidWeber

I have experienced the same problem on Galaxy tab and iPad 2.
What's the best way to tell if there's an error being thrown on a mobile device? Is it possible to get a debug console like the one in cocoonjs?

7 years ago by DavidWeber

Ok touch events binded to divs work fine on Android and iOS.

The following full canvas touch I could only get to work on Android.
var nX;
var nY;
var pressed = false;

Canvas.addEventListener('touchstart', function(event){
    nX = event.touches[0].pageX;
    nY = event.touches[0].pageY;
    pressed = true;
}, false);

if (ig.input.pressed('start') || ig.input.state('CanvasTouch') || pressed) {
            // do stuff
}

7 years ago by mmadaria

Hi, we're experiencing the same problem running our game on an iPad 2 (using the app lab launcher), so please tell us if there is a workaround to solve this.

Thanks in advance.

Milko.

7 years ago by TylerAppmobi

Hey All,

Sorry, I forgot to update this thread from which this question stemmed. I looked through the code and we accidently introduced this touch bug recently. We have a new appLab in the Apple submission process which should be put in the store fairly soon and fixes this issue.

I'll post here when it is in the app store.

7 years ago by GlergHendershmidt

Hello,

Has there been any update on this? I also have implemented a minimal test game that just writes the text values of nX and nY to the screen. Works in the emulator and on my iPhone 4s, but not on my Droid Razr, which always reports 'undefined'.

Also, somebody asked above about debugging on the device. Is there a way to see the console log in AppLab?

Thanks.

7 years ago by GlergHendershmidt

By the way, the workaround I have just implemented is to attach the touch event on the DOM side and send the x and y values over to the canvas context as follows:

window.document.addEventListener('touchstart', handleTouch, false);
			window.document.addEventListener('touchmove', handleTouch, false);
			function handleTouch(event){
				var nX=event.touches[0].pageX;
				var nY=event.touches[0].pageY;
				AppMobi.canvas.execute("nX="+nX + ";nY="+nY);
				
			}

I put this code in index.html (for now), right below the line:

window.document.addEventListener('touchmove', preventDefaultScroll, false);

7 years ago by GlergHendershmidt

BTW, while the above work around is functional, the performance is not good, so any insight on how to actually get touch events working in the Direct Canvas context on Android would be great.

7 years ago by TylerAppmobi

I'm traveling this week so my support won't be as in depth as usual, but right now we are working on fixing a bug in the Android directCanvas multi-touch / touch code. This should be fixed in our build system. Try creating an APK to see if it works.

The next time we push an Android appLab live it will contain this update.

Sorry about not posting back on this thread when we updated the Apple appLab, completely forgot.
Page 1 of 1
« first « previous next › last »