Legacy GM Rotate bone relative to the angle of the click on the touch button (Spine 2D)

wilmer

Member
Greetings to all:
Is this possible and can you pass me the code?, my character is animated in Spine and he shoots arrows when he releases a touch button, what I want is to see if I can use that button and not the same touch screen as in other games, for example if I have it pressed and my finger on the button I lower it or climb it a bit, rotate the arm bone like this:


This is the code I have:
Player Object / Create
:
Code:
globalvar xx;
globalvar bullet;
globalvar yy;
globalvar l_shoot;
globalvar shoot_angle;
Step event:
// The following code must find x / y of gun bone.

Code:
l_shoot = ds_map_create ();
skeleton_bone_state_get ("left_pistol", l_shoot); // left_pistol - points the bone where the bullets will be created
shoot_angle = l_shoot [? "angle"];
xx = x + l_shoot [? "worldX"]; // x and y of object
yy = y + l_shoot [? "worldY"];
ds_map_destroy (l_shoot);
// When releasing the button, launch arrow
Code:
if keyboard_check_released(ord("Z")){
    bullet = instance_create(xx,yy,obj_Arrow);
    bullet.gravity = .5;
    bullet.friction = .1;
    bullet.direction = 0;
    bullet.speed = 25 + random(3);

}
obj_Arrow / Event Step: // Object of the arrow
Code:
image_angle = direction
obj_btnArrow / Create Event: // Touch button to shoot the arrow
Code:
AddKey (ord ("Z"));// This is a simple Script for Virtual Keys
 
Last edited:

johnwo

Member
You're nearly there:
Get the current angle of the bone(s) with skeleton_bone_state_get, modify the variables in the map(s), then apply the changes with skeleton_bone_state_set.
Do this in the animation update event.
 

wilmer

Member
You're nearly there:
Get the current angle of the bone(s) with skeleton_bone_state_get, modify the variables in the map(s), then apply the changes with skeleton_bone_state_set.
Do this in the animation update event.
Thanks johnwo, the problem is that codes like that I look for in forums and I adapt them to my game, but I still need to know a lot and I don't have the head right now to write what you told me, I'm a graphic designer and I don't understand GML In its whole.
 
Top