[IOS CODE] The mouse, an enemy in the shadow..

Started by Erkosone, February 12, 2012, 01:19:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Erkosone


Example code to work with a simple mouse pointer on the touch screen of an iPhone or similar.


Please note:
- If the SIZE is zero there is no collision, then we will take advantage of this phenomenon for use in our codes.
- If the variable GLOBAL iOS_Release is 'FALSE' this code will act as a normal mouse pointer, this is useful whendesigning the application, let you hang iOS_Release = TRUE.
- The mouse pointer on a Touch Screen will be located right in the center of the llema the finger touches the screen, remaining below where we really want to play, this is taken into account in this code by a rectangular graphic color only in the upper half thereof, and collisions probocando above the actual position of incision on the screen.
- It is recognized that once you touch the screen, in that moment of time you can not see the collision, but you have to let a frame, this is so that the cursor is in the "last played position "we do not want that happening again a collision in that position, but at the current position, we will spend a FRAME before the collision check.


I hope you serve as a help, and make you spend less time than if you have to be discovering this for yourself little by little ..
All this assuming that eventually the mouse is connected to the touchscreen, which is easier if multitouch is not required.
Global Variables required: 'INT iOS_Release' 'INT G_Mouse' 'ID_Mouse'.



process raton();
begin
   if(ios_release==true)
      alpha=0;
         else
            alpha=255;
   end
   id_mouse=id;
   file=0;
   graph=G_Mouse;
   z=mouse.z;
   loop
      if(ios_release==true)
         if(!mouse.left)
            size=0;
               else
                  size=100;
         end
      end
      x=mouse.x;
      y=mouse.y;
      frame;
   end
end



# Method to check collision with the mouse now is: if (collision (ID_Mouse)) ......; End
# G_Mouse must be a 15x25 graphical, colored in the upper half thereof, the middle graph inferor must be transparent.