///////////////////////////////GRASS (BACKGROUND)//////////////////////////////// $goCommandThreshold = 12; function grass::onTouchDown(%this, %event) { // FIXME: if top-left corner, do not responde if (t2dVectorCompare(%event.point, 0 SPC 0, 0)) { return; } %tempFinger = new t2dStaticSprite() { imageMap = "moon_irisImageMap"; }; %tempFinger.setSize(15 SPC 15); %tempFinger.addToScene(sceneWindow2D.getSceneGraph()); %tempFinger.setPosition(%event.point); %tempFinger.setLifetime(0.8); $touchStartingPoint[%event.id] = new ScriptObject(){ point = %event.point; }; } function grass::onTouchMove(%this, %event) { // FIXME: if top-left corner, do not responde if (t2dVectorCompare(%event.point, 0 SPC 0, 0)) { return; } %tempFinger = new t2dStaticSprite() { imageMap = "moon_irisImageMap"; }; %tempFinger.setSize(15 SPC 15); %tempFinger.addToScene(sceneWindow2D.getSceneGraph()); %tempFinger.setPosition(%event.point); %tempFinger.setLifetime(0.8); } function grass::onTouchUp(%this, %event) { // FIXME: if top-left corner, do not responde if (t2dVectorCompare(%event.point, 0 SPC 0, 0)) { return; } %distance = t2dVectorDistance(%event.point, $touchStartingPoint[%event.id].point); $touchStartingPoint[%event.id].Delete(); if (%distance >= $goCommandThreshold){ $d3xpos = getWord(%event.point, 0)/$scaleunit; $d3ypos = getWord(%event.point, 1)/$scaleunit; //sendPosition($d3xpos, $d3ypos); echo("sending: ", $d3xpos, " and ", $d3ypos); alxPlay(roarSound); } } //////////////////////////////MOTHERBOARD/////////////////////////////////////////// function motherBoard::onTouchDown(%this, %event) { if(%this.downCount == 0){ alxPlay(clickSound); %this.downCount = 1; %this.schedule(500, "resetCount"); } else{ alxPlay(functionBornSound); %this.onTouchTwice(); %this.resetCount(); } } function motherBoard::resetCount(%this) { %this.downCount = 0; } $alterGenerator = 0; function motherBoard::onTouchTwice(%this) { if ($alterGenerator == 0) { %circle = new t2dStaticSprite() { ImageMap = "Picture0ImageMap"; Layer = 1; class = "sliderCircle"; }; %circle.setSize(20 SPC 20); %circle.setUseMouseEvents(true); %circle.setUseTouchEvents(true); %circle.setCollisionActive(1, 1); %circle.setWorldLimit("KILL", -$worldSizeX/2, -$worldSizeY/2, $worldSizeX/2, $worldSizeY/2, true); %slider = new t2dStaticSprite() { imageMap = "Picture2ImageMap"; class = "slider"; //superclass = "dragable"; }; //%slider.setConfigDatablock(touchableObjectDatablock); %slider.setSize(18 SPC 18); %slider.setUseMouseEvents(true); %slider.setUseTouchEvents(true); %circle.addToScene(sceneWindow2D.getSceneGraph()); %slider.addToScene(sceneWindow2D.getSceneGraph()); %circle.setPosition(t2dVectorAdd(%this.getPosition(), 18 SPC 10)); %slider.mount(%circle, 0, -2); $alterGenerator = 1; } else { %tempplus = new t2dStaticSprite() { imageMap = "_0950460ImageMap"; class = "enlargeButton"; }; %tempplus.setSize(20, 20); %tempplus.setBlendColor(0.5, 0.5, 0.5, 1); %tempplus.setUseMouseEvents(true); %tempplus.setUseTouchEvents(true); %tempplus.setCollisionActive(1, 1); %tempplus.setWorldLimit("KILL", -$worldSizeX/2, -$worldSizeY/2, $worldSizeX/2, $worldSizeY/2, true); %tempminus = new t2dStaticSprite() { imageMap = "_09504627ImageMap"; class = "reduceButton"; }; %tempminus.setSize(20, 20); %tempminus.setBlendColor(0.5, 0.5, 0.5, 1); %tempminus.setUseMouseEvents(true); %tempminus.setUseTouchEvents(true); %tempminus.setCollisionActive(1, 1); %tempminus.setWorldLimit("KILL", -$worldSizeX/2, -$worldSizeY/2, $worldSizeX/2, $worldSizeY/2, true); %tempplus.setPosition(t2dVectorAdd(%this.getPosition(), -18 SPC -10)); %tempminus.setPosition(t2dVectorAdd(%this.getPosition(), -18 SPC 10)); %tempplus.addToScene(sceneWindow2D.getSceneGraph()); %tempminus.addToScene(sceneWindow2D.getSceneGraph()); $alterGenerator = 0; } } ////////////////////////////////SLIDER/////////////////////////////////////////// function Slider::onTouchDown(%this, %event) { alxPlay(clickSound); } function Slider::onTouchMove(%this, %event) { %dashboard = %this.getMountedParent(); %dashPos = %dashboard.getPosition(); //%distance = t2dVectorDistance(%dashPos, %this.getPosition()); %biasAngle = mAtan((getWord(%event.point, 1)-getWord(%dashPos, 1))/(getWord(%event.point, 0)-getWord(%dashPos, 0)), 1); if ((getWord(%event.point, 0)-getWord(%dashPos, 0))>0) { %sliderRad = 1.57 + %biasAngle; %biasX = mCos(%biasAngle); %biasY = mSin(%biasAngle); } else { %sliderRad = %biasAngle - 1.57; %biasX = - mCos(%biasAngle); %biasY = - mSin(%biasAngle); } //%this.setPosition(t2dVectorAdd(%dashPos, %biasX SPC %biasY)); //sendRotation(%sliderRad); %this.mount(%dashboard, %biasX*2, %biasY*2); } //////////////////////////////////SLIDER CIRCLE///////////////////////////////////////// function sliderCircle::onTouchDown(%this, %event) { alxPlay(clickSound); %this.dx = getWord(%event.point, 0) - %this.getPositionX(); %this.dy = getWord(%event.point, 1) - %this.getPositionY(); } function sliderCircle::onTouchMove(%this, %event) { %this.setPosition(getWord(%event.point, 0)-%this.dx, getWord(%event.point, 1)-%this.dy); } ////////////////////ENLARGE BUTTON//////////////////////////////////// function enlargeButton::onTouchDown(%this, %event) { alxPlay(clickSound); %this.setBlendColor(1, 1, 1, 1); //sendResizing(1.25); echo("Enlarge!"); //%this.schedule(100, "setBlendColor", 1,1,1,1); footprint0.setSize(t2dVectorScale(footprint0.getSize(), 1.25)); footprint1.setSize(t2dVectorScale(footprint1.getSize(), 1.25)); $offset = $offset*1.25; %this.dx = getWord(%event.point, 0) - %this.getPositionX(); %this.dy = getWord(%event.point, 1) - %this.getPositionY(); } function enlargeButton::onTouchMove(%this, %event) { //%oldPosition = %this.getPosition(); //%this.setPosition(t2dVectorAdd(%oldPosition, %dX SPC %dY)); %this.setPosition(getWord(%event.point, 0)-%this.dx, getWord(%event.point, 1)-%this.dy); } function enlargeButton::onTouchUp(%this, %event) { %this.setBlendColor(0.5, 0.5, 0.5, 1); } //////////////////REDUCE BUTTON//////////////////////////////////// function reduceButton::onTouchDown(%this, %event) { alxPlay(clickSound); %this.setBlendColor(1, 1, 1, 1); //sendResizing(0.8); echo("Reduce!"); //%this.schedule(100, "setBlendColor", 1,1,1,1); footprint0.setSize(t2dVectorScale(footprint0.getSize(), 0.8)); footprint1.setSize(t2dVectorScale(footprint1.getSize(), 0.8)); $offset = $offset*0.8; %this.dx = getWord(%event.point, 0) - %this.getPositionX(); %this.dy = getWord(%event.point, 1) - %this.getPositionY(); } function reduceButton::onTouchMove(%this, %event) { %this.setPosition(getWord(%event.point, 0)-%this.dx, getWord(%event.point, 1)-%this.dy); } function reduceButton::onTouchUp(%this, %event) { %this.setBlendColor(0.5, 0.5, 0.5, 1); }