Hallo,
ich habe ein Problem, die Maus bleibt nicht im Fenster und somit am Sprite geknüpft. Habe einige Experimente mit "paddle=mouse_x" gestartet. Habe auch hier im Forum nach Lösungsansätzen gesucht, in bezug auf die Maussteuerung: leider half mir nichts dabei.
So ist das Objekt als ganzes aufgebaut:
Sprite: Paddle
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
create particle system at drawing depth 1
create particle type 0 to have shape pixel, size between 1 and 1, and color going from 65535 to 255
set the life time for particle type 0 to lie between 1 and 5
set the speed for particle type 0 to lie between 1 and 4, the direction between Paddle.x+0 and Paddle.x+0, and the friction to 1
set the gravity for particle type 0 to 2 in direction 0
set variable can_shoot to 1
Alarm Event for alarm 1:
set variable can_shoot to 1
Step Event:
burst 250 particles of type 0 from emitter 0
execute code:
{
//Steuerung, gegenwärtig
x = mouse_x;
if (x-sprite_width = global.field_left)
x=global.field_left+sprite_width;
if (x+sprite_width = global.field_right)
x=global.field_right-sprite_width;
}
Begin Step Event:
create emitter 0 with shape rectangle of area Paddle.x+0 - Paddle.x-5 by Paddle.y+0 - Paddle.y-2
Collision Event with object ball_main:
execute code:
{
if (other.x < x)
{other.direction = 110 + 80*(x-other.x)/sprite_width;}
else
{other.direction = 70 + 80*(x-other.x)/sprite_width;}
if (other.y > y)other.direction :=360-other.direction;
}
play sound ballhit; looping: false
Collision Event with object Wall_y:
move relative to position (0,0)
Collision Event with object ball_2:
execute code:
{
if (other.x < x)
{other.direction = 110 + 80*(x-other.x)/sprite_width;}
else
{other.direction = 70 + 80*(x-other.x)/sprite_width;}
if (other.y > y)other.direction :=360-other.direction;
}
play sound ballhit; looping: false
Collision Event with object add_life:
set the number of lives relative to +1
play sound extralive; looping: false
for all add_life: destroy the instance
Keyboard Event for <Ctrl> Key:
if can_shoot is equal to 1
set Alarm 1 relative to 100
set variable can_shoot to 0
play sound ball_rclaser; looping: false
create instance of object ball_rclaser at relative position (-28,0)
create instance of object ball_rclaser at relative position (24,0)
Viel Zeit und Tränen haben fließen müssen bis ich erkannte das ich dem Problem nicht selbst auf die Schliche komme...
Danke im voraus... !!!
ich habe ein Problem, die Maus bleibt nicht im Fenster und somit am Sprite geknüpft. Habe einige Experimente mit "paddle=mouse_x" gestartet. Habe auch hier im Forum nach Lösungsansätzen gesucht, in bezug auf die Maussteuerung: leider half mir nichts dabei.
So ist das Objekt als ganzes aufgebaut:
Sprite: Paddle
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
create particle system at drawing depth 1
create particle type 0 to have shape pixel, size between 1 and 1, and color going from 65535 to 255
set the life time for particle type 0 to lie between 1 and 5
set the speed for particle type 0 to lie between 1 and 4, the direction between Paddle.x+0 and Paddle.x+0, and the friction to 1
set the gravity for particle type 0 to 2 in direction 0
set variable can_shoot to 1
Alarm Event for alarm 1:
set variable can_shoot to 1
Step Event:
burst 250 particles of type 0 from emitter 0
execute code:
{
//Steuerung, gegenwärtig
x = mouse_x;
if (x-sprite_width = global.field_left)
x=global.field_left+sprite_width;
if (x+sprite_width = global.field_right)
x=global.field_right-sprite_width;
}
Begin Step Event:
create emitter 0 with shape rectangle of area Paddle.x+0 - Paddle.x-5 by Paddle.y+0 - Paddle.y-2
Collision Event with object ball_main:
execute code:
{
if (other.x < x)
{other.direction = 110 + 80*(x-other.x)/sprite_width;}
else
{other.direction = 70 + 80*(x-other.x)/sprite_width;}
if (other.y > y)other.direction :=360-other.direction;
}
play sound ballhit; looping: false
Collision Event with object Wall_y:
move relative to position (0,0)
Collision Event with object ball_2:
execute code:
{
if (other.x < x)
{other.direction = 110 + 80*(x-other.x)/sprite_width;}
else
{other.direction = 70 + 80*(x-other.x)/sprite_width;}
if (other.y > y)other.direction :=360-other.direction;
}
play sound ballhit; looping: false
Collision Event with object add_life:
set the number of lives relative to +1
play sound extralive; looping: false
for all add_life: destroy the instance
Keyboard Event for <Ctrl> Key:
if can_shoot is equal to 1
set Alarm 1 relative to 100
set variable can_shoot to 0
play sound ball_rclaser; looping: false
create instance of object ball_rclaser at relative position (-28,0)
create instance of object ball_rclaser at relative position (24,0)
Viel Zeit und Tränen haben fließen müssen bis ich erkannte das ich dem Problem nicht selbst auf die Schliche komme...
Danke im voraus... !!!
Dieser Beitrag wurde ausgezeichnet mit einem großen LOB.