Guten Tag,
Ich habe in einem Beispiel unter dem object "obj_spieler" - Draw Event dieses Skript entfernt. Da Ich etwas anderes einbauen musste, da ansonsten dieser Skript nicht funktioniert.
Folgendes Skript:
Alles anzeigen
Der ging unter Draw-Event vom obj_spieler Perfekt. Nun habe Ich es auf einem neuen Object hineingezogen, auch unter Draw-Event. Nun muss Ich das so anpassen, dass es wieder um den obj_spieler handelt. Leider bin ich hier gescheitert. Ich hoffe, Ihr könntet mir dabei helfen.
Ich habe versucht in dem Skript unter //////ship controls////// Zeile
So in etwa einzubauen:
Ich dachte mir, nur diese Zeile währ wichtig. Da hier der Spieler gesteuert werden soll.
Vielen Dank im vorraus!
Mfg,
DefZombie
Ich habe in einem Beispiel unter dem object "obj_spieler" - Draw Event dieses Skript entfernt. Da Ich etwas anderes einbauen musste, da ansonsten dieser Skript nicht funktioniert.
Folgendes Skript:
GML-Quellcode
- //////// Analog Stick Math ///////////
- //resets analog stick
- if(control_type=0){
- analog_distance=0;
- point_x=(analog_x+analog_width/2)+analog_distance*(cos(analog_direction*pi/180))+view_xview;
- point_y=(analog_y+analog_height/2)+analog_distance*(sin(analog_direction*pi/180))+view_yview;
- //check for if the finger is still being held for the analog
- if (!device_mouse_check_button(device_used,mb_left)){
- device_used=-1;
- }
- //analog stick equations
- for(ddevice=0;ddevice<=4;ddevice+=1){
- if (device_mouse_check_button(ddevice,mb_left) and (device_mouse_x(ddevice)>analog_x+view_xview-deadzone and device_mouse_y(ddevice)>analog_y+view_yview-deadzone and device_mouse_x(ddevice)<analog_x+analog_width+view_xview+deadzone and device_mouse_y(ddevice)<analog_y+analog_height+view_yview+deadzone) or device_used=ddevice){
- device_used=ddevice;
- //math behind distance and direction
- analog_direction = radtodeg(arctan2((device_mouse_y(ddevice)-(analog_y+view_yview+analog_height/2)),(device_mouse_x(ddevice)-(analog_x+view_xview+analog_width/2)+.000001)));
- analog_direction_ship = radtodeg(arctan2(-(device_mouse_y(ddevice)-(analog_y+view_yview+analog_height/2)),(device_mouse_x(ddevice)-(analog_x+view_xview+analog_width/2)+.000001)));
- analog_distance = sqrt(sqr(device_mouse_x(ddevice)-(analog_x+view_xview+analog_width/2))+sqr(device_mouse_y(ddevice)-(analog_y+view_yview+analog_height/2)));;
- //sets deadzone for the analog stick
- if(analog_distance>analog_width/2){analog_distance=analog_width/2;}
- if(analog_distance<-analog_width/2){analog_distance=analog_width/2;}
- //points where the stick is
- point_x=(analog_x+analog_width/2)+analog_distance*(cos(analog_direction*pi/180))+view_xview;
- point_y=(analog_y+analog_height/2)+analog_distance*(sin(analog_direction*pi/180))+view_yview;
- [b] /// control ship[/b]
- direction=analog_direction_ship;
- speed=(analog_distance/(analog_width/2))*ship_speed;
- }
- if(os_type==os_win32 || os_type==os_linux || os_type==os_macosx){
- if (device_mouse_check_button(ddevice,mb_left) and device_mouse_x(ddevice)>virtual_x/2 and device_mouse_y(ddevice)>virtual_y/2 and device_mouse_x(ddevice)<(virtual_x+virtual_width)*1.5 and device_mouse_y(ddevice)<(virtual_y+virtual_height)*1.5){
- event_perform(ev_keyboard,vk_space);
- }}
- }
- ///////////////// End Analog Stick ///////////////////////
- //friction for ship
- if((analog_distance/(analog_width/2))*ship_speed<1 and speed>0){speed-=ship_friction; if(speed<0){speed=0;}}
- if(x<view_xview){x+=speed;}if(x>view_xview+view_wport){x-=speed;}
- if(y<view_yview){y+=speed;}if(y>view_yview+view_hport){y-=speed;}
- }
Der ging unter Draw-Event vom obj_spieler Perfekt. Nun habe Ich es auf einem neuen Object hineingezogen, auch unter Draw-Event. Nun muss Ich das so anpassen, dass es wieder um den obj_spieler handelt. Leider bin ich hier gescheitert. Ich hoffe, Ihr könntet mir dabei helfen.
Ich habe versucht in dem Skript unter //////ship controls////// Zeile
So in etwa einzubauen:
Ich dachte mir, nur diese Zeile währ wichtig. Da hier der Spieler gesteuert werden soll.
Vielen Dank im vorraus!
Mfg,
DefZombie
