Hey luffy50660,
first of all,
clear created "objects" and set it to NULL, to let dangling pointer no chance to act.
If i understand your problem right, you wanna use a custom mouse cursor picture, instead of the OS Cursor?
sfWindow_setMouseCursorVisible(window, sfFalse);
// Sets the OS Cursor invisible
...
sfSprite_setTexture(cursor, texture2, sfTrue);
// Sets your custom texture to the sprite
...
sfVector2i cursor_coord;
cursor_coord.x = 1280;
cursor_coord.y = 769;
sfMouse_setPosition(cursor_coord, window);
// Sets your invisible OS Mouse Cursor at application start to bottom right
// there is no sense in there
...
In your main loop, i dont find anything about update your cursor position.
------------------------------------
First set the Initial Position of Your Cursor Sprite and update it in your main loop.
I made some minimal running example.
#include <stdio.h>
#include <stdlib.h>
#include <SFML/Audio.h>
#include <SFML/Graphics.h>
#include <SFML/Window.h>
#include <SFML/System.h>
int main()
{
// Variables
sfVideoMode mode = {600, 600, 32};
sfEvent EventLoop;
sfRenderWindow *screen;
sfSprite *Cursor_Sprite;
sfTexture *Cursor_Texture;
sfVector2f Cursor_Position;
// Init Stuff
screen = sfRenderWindow_create(mode, "Minimal Example", sfClose, NULL);
Cursor_Texture = sfTexture_createFromFile("MouseCursor.png", sfFalse);
Cursor_Sprite = sfSprite_create();
// Check created Stuff
if(screen == NULL || Cursor_Sprite == NULL || Cursor_Texture == NULL)
return 0;
// Get Initial Position
Cursor_Position.x = sfMouse_getPosition(screen).x;
Cursor_Position.y = sfMouse_getPosition(screen).y;
// Set Texture to Sprite
sfSprite_setTexture(Cursor_Sprite, Cursor_Texture, sfFalse);
sfSprite_setPosition(Cursor_Sprite, Cursor_Position);
// Set Windows Cursor invisible
sfRenderWindow_setMouseCursorVisible(screen, sfFalse);
// Main Loop
while (sfRenderWindow_isOpen(screen))
{
// Proceed Events
while (sfRenderWindow_pollEvent(screen, &EventLoop))
{
if(EventLoop.type == sfEvtClosed)
sfRenderWindow_close(screen);
}
// Update Stuff
Cursor_Position.x = sfMouse_getPosition(screen).x;
Cursor_Position.y = sfMouse_getPosition(screen).y;
sfSprite_setPosition(Cursor_Sprite, Cursor_Position);
// Draw Stuff
sfRenderWindow_drawSprite(screen, Cursor_Sprite, NULL);
// Display it
sfRenderWindow_display(screen);
// Clear Window
sfRenderWindow_clear(screen, sfBlack);
}
// Clean up
sfSprite_destroy(Cursor_Sprite);
Cursor_Sprite = NULL;
sfTexture_destroy(Cursor_Texture);
Cursor_Texture = NULL;
sfRenderWindow_destroy(screen);
screen = NULL;
return 0;
}
Hope that will solve your problem
Greetz MOP
@Exploiter
passing argument 1 of 'sfMouse_getPosition' from incompatible pointer type [-Wincompatible-pointer-types]
Please make an update for csfml, and make magic stuff with CPP.
I saw a topic about this at the year: on: 2012
https://en.sfml-dev.org/forums/index.php?topic=7761.msg51675#msg51675Thats atleast 5 Years...
Is there no support anymore for the C Binding ? That makes me sad...