Sayfayı Yazdır | Pencereyi Kapat

Animasyon kullanımında sorun yaşıyorum

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=930
Tarih: 06 Ocak 2025 Saat 12:38
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: Animasyon kullanımında sorun yaşıyorum
Mesajı Yazan: steelwing
Konu: Animasyon kullanımında sorun yaşıyorum
Mesaj Tarihi: 11 Eylül 2024 Saat 09:44
Animasyonumu istediğim şekilde çalıştıramıyorum. Çalışsa bile animasyon bittikten sonra clomosy uygulamasından atıyor.



Cevaplar:
Mesajı Yazan: steelwing
Mesaj Tarihi: 11 Eylül 2024 Saat 13:57
var
  MyForm: TclGameForm;
  AnaForm:TclGameForm; 
  animasyon1:TclBitmapListAnimation; 
  rectangle: Tclrectangle;  
  ImgRifle, ImgSavan: TclProImage;
  DeviceMotionSensor: TClMotionSensor;
  LblDisplay: TclLabel;
  GameTimer: TclTimer;
  geribtn, BtnFire: TClProButton;
  circle1, circle2: tclcircle;
  SoundIndex: Integer;
  myDeviceManager: TclDeviceManager;
  number: Integer;

procedure geriprcdr;
begin
  TclProButton(MyForm.clFindComponent('BtnGoBack')).Click;
end;

procedure InitializeComponents;
begin
  MyForm := TclGameForm.Create(Self);
  myDeviceManager := TclDeviceManager.Create;

  LblDisplay := MyForm.AddNewLabel(MyForm, 'LblDisplay', '--');
  LblDisplay.Align := alTop;
  LblDisplay.Visible := False;

  // Initialize Joystick Circles
  circle1 := MyForm.AddNewCircle(MyForm, 'circle1');
  circle1.Align := alNone;
  circle1.Width := 100;  
  circle1.Height := 100;
  circle1.Position.X := MyForm.clWidth / 8;
  circle1.Position.Y := MyForm.clHeight * 83 / 150;

  circle2 := MyForm.AddNewCircle(MyForm, 'circle2'); 
  circle2.Align := alNone;
  circle2.Width := 40;  
  circle2.Height := 40; 
  circle2.Position.X := circle1.Position.X + 30;
  circle2.Position.Y := circle1.Position.Y + 30;
  circle2.Visible := true;

  geribtn := MyForm.AddNewProButton(MyForm, 'geribtn', '');
  clComponent.SetupComponent(geribtn, '{"Align" : "None","Width":70,"Height":50,"ImgUrl":" https://i.imgur.com/XUYO0A6.png" rel="nofollow - https://i.imgur.com/XUYO0A6.png" }');
  MyForm.AddNewEvent(geribtn, tbeOnClick, 'geriprcdr');
  geribtn.Position.X := 5;
  geribtn.Position.Y := 7;

  ImgSavan := MyForm.AddNewProImage(MyForm, 'ImgSavan');
  ImgSavan.clSetImage(' https://i.hizliresim.com/tw0gudt.png" rel="nofollow - https://i.hizliresim.com/tw0gudt.png ');
  ImgSavan.Width := 800;
  ImgSavan.Height := 800;
  ImgSavan.Align := alCenter;
  ImgSavan.Position.X := 0;
  ImgSavan.Position.Y := 0;
  ImgSavan.hittest := false;
  clRTMethod(ImgSavan, 'SendToBack');

  ImgRifle := MyForm.AddNewProImage(MyForm, 'ImgRifle');
  ImgRifle.clSetImage(' https://i.imgur.com/o5kq53m.png" rel="nofollow - https://i.imgur.com/o5kq53m.png ');
  ImgRifle.Width := 150;
  ImgRifle.Height := 150;
  ImgRifle.Align := alNone;
  ImgRifle.Position.X := 180;
  ImgRifle.Position.Y := 250;
  MyForm.AddNewEvent(circle1, tbeOnMouseMove, 'MoveCircles');
  ImgRifle.hittest := false;

  BtnFire := MyForm.AddNewProButton(MyForm, 'BtnFire', '');
  BtnFire.Align := alNone;
  BtnFire.Width := 70;
  BtnFire.Height := 50;
  BtnFire.Position.X := 290;
  BtnFire.Position.Y := 550;
  BtnFire.clProSettings.PictureSource := ' https://i.imgur.com/HrjM4pf.png" rel="nofollow - https://i.imgur.com/HrjM4pf.png ';
  BtnFire.SetclProSettings(BtnFire.clProSettings);
  MyForm.AddNewEvent(BtnFire, tbeOnClick, 'BtnFireClick');

  GameTimer := MyForm.AddNewTimer(MyForm, 'GameTimer', 5);
  GameTimer.Enabled := TRUE;
  MyForm.AddNewEvent(GameTimer, tbeOnTimer, 'MoveCircles');
end;

procedure MoveCircles;
var
  NewX, NewY: Single;
begin
  // Joystick hareketi
  if (circle2.Position.X < MyForm.clFormMousePosX) then
  begin
    if (circle2.Position.X < circle1.Position.X + circle1.Height * 2 / 3) then
    begin
      circle2.Visible := True;
      circle2.Position.X := circle2.Position.X + 3;
    end;
  end
  else if (circle2.Position.X > MyForm.clFormMousePosX) then
  begin
    if (MyForm.clFormMousePosX > 0) then
    begin
      if (circle2.Position.X > circle1.Position.X) then
      begin
        circle2.Visible := True;
        circle2.Position.X := circle2.Position.X - 3;
      end;
    end;
  end;

  if (circle2.Position.Y < MyForm.clFormMousePosY) then
  begin
    if (circle2.Position.Y < circle1.Position.Y + circle1.Width * 2 / 3) then
    begin
      circle2.Visible := True;
      circle2.Position.Y := circle2.Position.Y + 3;
    end;
  end
  else if (circle2.Position.Y > MyForm.clFormMousePosY) then
  begin
    if (MyForm.clFormMousePosY > 0) then
    begin
      if (circle2.Position.Y > circle1.Position.Y) then
      begin
        circle2.Visible := True;
        circle2.Position.Y := circle2.Position.Y - 3;
      end;
    end;
  end;
  
   
  begin
  AnaForm := TCLGameForm.Create(Self); 
  AnaForm.AddGameAssetFromUrl(' https://i.imgur.com/BedqHXr.jpeg" rel="nofollow - https://i.imgur.com/BedqHXr.jpeg '); 
 
  rectangle := AnaForm.AddNewCircle(AnaForm, 'rectangle'); 
  rectangle.Fill.Kind := fbkBitmap; 
  rectangle.Fill.Bitmap.WrapMode := fbwmTileStretch; 
  rectangle.Width := 650;  
  rectangle.Height := 620; 
  rectangle.Stroke.Thickness := 1; 
 
  animasyon1 := AnaForm.AddNewBitmapListAnimation(rectangle,'animasyon1');  
  animasyon1.AnimationBitmap.LoadFromFile(clomosy.appfilespath + '/BedqHXr.jpeg'); 
  animasyon1.Stop;  
  animasyon1.AnimationCount := 6; 
  animasyon1.AnimationRowCount := 2; 
  animasyon1.Delay := 0; 
  animasyon1.Duration := 0.75; 
  animasyon1.AutoReverse := True; 
  animasyon1.Enabled := True; 
  animasyon1.Loop := True; 
  animasyon1.Start; 
  AnaForm.Run; 
end;

  // ImgRifle'nin Joystick'e göre hareketi
  NewX := ImgRifle.Position.X + (circle2.Position.X - (circle1.Position.X + 30)) / 10;
  NewY := ImgRifle.Position.Y + (circle2.Position.Y - (circle1.Position.Y + 30)) / 10;

  // Sınır kontrolleri
  if NewX < 0 then
    NewX := 0
  else if NewX > MyForm.clWidth - ImgRifle.Width then
    NewX := MyForm.clWidth - ImgRifle.Width;

  if NewY < 0 then
    NewY := 0
  else if NewY > MyForm.clHeight - ImgRifle.Height then
    NewY := MyForm.clHeight - ImgRifle.Height;

  // Pozisyonu güncelle
  ImgRifle.Position.X := NewX;
  ImgRifle.Position.Y := NewY;

  // Joystick resetleme
  if (MyForm.clFormMousePosX < 0) then
  begin
    circle2.Position.X := circle1.Position.X + 30;
    circle2.Position.Y := circle1.Position.Y + 30;
    circle2.Visible := False;
  end;
end;

begin
  InitializeComponents;
  if Clomosy.PlatformIsMobile then
    MyForm.Run;
end;



Mesajı Yazan: Developer
Mesaj Tarihi: 11 Eylül 2024 Saat 15:17
Merhaba Steelwing,
 AnaForm := TCLGameForm.Create(Self); 
  AnaForm.AddGameAssetFromUrl(' https://i.imgur.com/BedqHXr.jpeg" rel="nofollow - https://i.imgur.com/BedqHXr.jpeg '); 
 
  rectangle := AnaForm.AddNewCircle(AnaForm, 'rectangle'); 
  rectangle.Fill.Kind := fbkBitmap; 
  rectangle.Fill.Bitmap.WrapMode := fbwmTileStretch; 
  rectangle.Width := 650;  
  rectangle.Height := 620; 
  rectangle.Stroke.Thickness := 1; 
 
  animasyon1 := AnaForm.AddNewBitmapListAnimation(rectangle,'animasyon1');  
  animasyon1.AnimationBitmap.LoadFromFile(clomosy.appfilespath + '/BedqHXr.jpeg'); 
  animasyon1.Stop;  
  animasyon1.AnimationCount := 6; 
  animasyon1.AnimationRowCount := 2; 
  animasyon1.Delay := 0; 
  animasyon1.Duration := 0.75; 
  animasyon1.AutoReverse := True; 
  animasyon1.Enabled := True; 
  animasyon1.Loop := True; 
  animasyon1.Start; 
  AnaForm.Run; 
Bu kod her seferinde tekrar çalışıyor. Bu hata bundan kaynaklı.



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net