Von Draw-entfernt -> auf ein neues Object

  • GM 8

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Von Draw-entfernt -> auf ein neues Object

    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:

    GML-Quellcode

    1. //////// Analog Stick Math ///////////
    2. //resets analog stick
    3. if(control_type=0){
    4. analog_distance=0;
    5. point_x=(analog_x+analog_width/2)+analog_distance*(cos(analog_direction*pi/180))+view_xview;
    6. point_y=(analog_y+analog_height/2)+analog_distance*(sin(analog_direction*pi/180))+view_yview;
    7. //check for if the finger is still being held for the analog
    8. if (!device_mouse_check_button(device_used,mb_left)){
    9. device_used=-1;
    10. }
    11. //analog stick equations
    12. for(ddevice=0;ddevice<=4;ddevice+=1){
    13. 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){
    14. device_used=ddevice;
    15. //math behind distance and direction
    16. 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)));
    17. 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)));
    18. 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)));;
    19. //sets deadzone for the analog stick
    20. if(analog_distance>analog_width/2){analog_distance=analog_width/2;}
    21. if(analog_distance<-analog_width/2){analog_distance=analog_width/2;}
    22. //points where the stick is
    23. point_x=(analog_x+analog_width/2)+analog_distance*(cos(analog_direction*pi/180))+view_xview;
    24. point_y=(analog_y+analog_height/2)+analog_distance*(sin(analog_direction*pi/180))+view_yview;
    25. [b] /// control ship[/b]
    26. direction=analog_direction_ship;
    27. speed=(analog_distance/(analog_width/2))*ship_speed;
    28. }
    29. if(os_type==os_win32 || os_type==os_linux || os_type==os_macosx){
    30. 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){
    31. event_perform(ev_keyboard,vk_space);
    32. }}
    33. }
    34. ///////////////// End Analog Stick ///////////////////////
    35. //friction for ship
    36. if((analog_distance/(analog_width/2))*ship_speed<1 and speed>0){speed-=ship_friction; if(speed<0){speed=0;}}
    37. if(x<view_xview){x+=speed;}if(x>view_xview+view_wport){x-=speed;}
    38. if(y<view_yview){y+=speed;}if(y>view_yview+view_hport){y-=speed;}
    39. }
    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:

    GML-Quellcode

    1. direction=obj_spieler.analog_direction_ship;
    2. speed=(obj_spieler.analog_distance/(analog_width/2))*ship_speed;


    Ich dachte mir, nur diese Zeile währ wichtig. Da hier der Spieler gesteuert werden soll.
    Vielen Dank im vorraus!




    Mfg,
    DefZombie :)
  • Hey!
    Versuch mal folgendes:

    GML-Quellcode

    1. obj_spieler.direction=analog_direction_ship;
    2. obj_spieler.speed=(analog_distance/(analog_width/2))*ship_speed;


    Ich glaube, dass du "obj_spieler" an die falsche Stelle gesetzt hast.
    Ich hoffe, dass es nun funktioniert.
    Viel Erfolg!

    "Make love, not Warcraft"