Touch Not Working With Ejecta

Get help using Construct 2

Post » Thu Sep 19, 2013 11:57 am

After throwing the towel in as I could not get my project to export properly with CocoonJS I am having issues with Ejecta.

My project loads but touch does not work - buttons have no response. I had some code I had to hash-out to get it going:

14725        var instanceProto = pluginProto.Instance.prototype;
14726        instanceProto.onCreate = function()
14727        {
14728                 var self = this;
14729                 if (!this.runtime.isEjecta)
14730                 {
14731                         jQuery(document).mousemove(
14732                                 function(info) {
14733                                         self.onMouseMove(info);
14734                                 }
14735                         );
14736                         jQuery(document).mousedown(
14737                                 function(info) {
14738                                         self.onMouseDown(info);
14739                                 }
14740                         );
14741                         jQuery(document).mouseup(
14742                                 function(info) {
14743                                         self.onMouseUp(info);
14744                                 }
14745                         );
14746                         jQuery(document).dblclick(
14747                                 function(info) {
14748                                         self.onDoubleClick(info);
14749                                 }
14750                         );
14751                         var wheelevent = function(info) {
14752                                                                self.onWheel(info);
14753                                                         };
14754                         document.addEventListener("mousewheel", wheelevent, false);
14755                         document.addEventListener("DOMMouseScroll", wheelevent, false);
14756                 }
14757        };

This final export process is doing my head in, been working on it for 3 days now - I thought this part would be no problem.
B
10
Posts: 30
Reputation: 940

Post » Thu Sep 19, 2013 12:03 pm

I don't think buttons work with CocoonJS. I was told to use touch sprites. Maybe it's the same with Ejecta?
B
45
S
15
G
73
Posts: 2,002
Reputation: 43,386

Post » Thu Sep 19, 2013 12:33 pm

[QUOTE=plinkie] I don't think buttons work with CocoonJS. I was told to use touch sprites. Maybe it's the same with Ejecta?[/QUOTE]


Yes I am using touch sprites.
B
10
Posts: 30
Reputation: 940

Post » Thu Sep 19, 2013 2:28 pm

So you have the touch object in your project now and not the mouse object. Correct?
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Thu Sep 19, 2013 5:53 pm

[QUOTE=ArcadEd] So you have the touch object in your project now and not the mouse object. Correct?[/QUOTE]


Yes exactly, at first I added the mouse object to test on the PC and (once I found buttons did not work with CocoonJS) I created sprites for each button using touch.weisdaclick2013-09-19 17:55:59
B
10
Posts: 30
Reputation: 940

Post » Fri Sep 20, 2013 2:56 am

Here is my error from XCode, perhaps someone can help with it.


2013-09-19 12:46:23.372 Ejecta[11576:907] ReferenceError: Can't find variable: jQuery at line 16464 in c2runtime.js
2013-09-19 12:46:27.730 Ejecta[11576:907] ReferenceError: Can't find variable: jQuery at line 16464 in c2runtime.js
2013-09-19 12:46:29.053 Ejecta[11576:907] ReferenceError: Can't find variable: jQuery at line 16464 in c2runtime.js
2013-09-19 12:46:29.553 Ejecta[11576:907] ReferenceError: Can't find variable: jQuery at line 16464 in c2runtime.js
2013-09-19 12:46:29.804 Ejecta[11576:907] ReferenceError: Can't find variable: jQuery at line 16464 in c2runtime.js


And the relevant lines in c2runtime.js...


16460        instanceProto.onTouchStart = function (info)
16461        {
16462                 if (info.preventDefault)
16463                         info.preventDefault();
16464                 var offset = this.runtime.isDomFree ? dummyoffset : jQuery(this.runtime.canvas).offset();
16465                 var nowtime = cr.performance_now();
16466                 var i, len, t, j;
16467                 for (i = 0, len = info.changedTouches.length; i < len; i++)
16468                 {
16469                         t = info.changedTouches;
16470                         j = this.findTouch(t["identifier"]);
16471                         if (j !== -1)
16472                                 continue;
16473                         var touchx = t.pageX - offset.left;
16474                         var touchy = t.pageY - offset.top;
16475                         this.trigger_index = this.touches.length;
16476                         this.trigger_id = t["identifier"];
16477                         this.touches.push({ time: nowtime,
16478                                                                x: touchx,
16479                                                                y: touchy,
16480                                                                lasttime: nowtime,
16481                                                                lastx: touchx,
16482                                                                lasty: touchy,
16483                                                                "id": t["identifier"],
16484                                                                startindex: this.trigger_index
16485                                                         });
16486                         this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchStart, this);
16487                         this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchStart, this);
16488                         this.curTouchX = touchx;
16489                         this.curTouchY = touchy;
16490                         this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchObject, this);
16491                 }
16492        };
B
10
Posts: 30
Reputation: 940


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests