mouse click- auto move player

Status
Not open for further replies.

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
So, I am trying to make a game where the player character is basically just a cursor, but I want to be able to click on the screen and have it instantly transport to that location. I was going to use conditional branch, when mouse button click or whatever, to just set player location, however I can't seem to find that option. Thanks for the help.
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
YOU would be rad! I am in no rush, so take your time.
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Okay, I might be doing something wrong, but I made a *.js file of the code, I put it into the plugins and turned it to on, but when I mouse click in game, the player just walks over...
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
Okay, I might be doing something wrong, but I made a *.js file of the code, I put it into the plugins and turned it to on, but when I mouse click in game, the player just walks over...
It should have worked.

Even if you just add this inside a JS file, it should work:

Code:
Game_Temp.prototype.setDestination = function(x, y) {    $gamePlayer.setPosition(x, y);};
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Well, I think I might just be mighty slow. I removed the comment (/) and it seemed to work just fine. Would I be an rear end in a top hat if I requested functionality that would allow interaction with Events? I was going to do a conditional branch, 'player x/player y, (WHen player x,y is =to stored variable x,y then do this..." but I cant seem to find a method for it..

Thanks for the script
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
Made a separate plugin just for you, you can remove that other one:

Code:
/*=============================================================================
* PhilteredKhaos Cursor
* By Hudell - www.hudell.com
* PhilteredKhaosCursor.js
* Version: 1.0
* Free for commercial and non commercial use.
*=============================================================================*/

/*:
* @plugindesc This plugin will instantly teleport the player to the clicked position
* @author Hudell
*/

var Imported = Imported || {};
var PhilteredKhaosCursor = PhilteredKhaosCursor || {};


(function($) {
  "use strict";
  Scene_Map.prototype.tryTriggeringEvent = function() {
    if ($gameMap.isAnyEventStarting() || $gameMap.isEventRunning() || !$gamePlayer.canStartLocalEvents()) {
      return false;
    }

    if (TouchInput.isTriggered() || this._touchCount > 0) {
      if (TouchInput.isPressed()) {
        if (this._touchCount === 0 || this._touchCount >= 15) {
          var x = $gameMap.canvasToMapX(TouchInput.x);
          var y = $gameMap.canvasToMapY(TouchInput.y);
          var events = $gameMap.eventsXy(x, y);
          if (events.length === 0) {
            return false;
          }

          for (var i = 0; i < events.length; i++) {
            if (events[i].isTriggerIn([0, 1, 2])) {
              events[i].start();
              return true;
            }
          }
        }
      }
    }
    return false;
  };

  Game_Temp.prototype.setDestination = function(x, y) {
    $gamePlayer.setPosition(x, y);
  };

  var oldSceneMap_processMapTouch = Scene_Map.prototype.processMapTouch;
  Scene_Map.prototype.processMapTouch = function() {
    this.tryTriggeringEvent();
    oldSceneMap_processMapTouch.call(this);
  };

})(PhilteredKhaosCursor);

Imported["PhilteredKhaosCursor"] = true;
 
Last edited:

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Man i feel dense, and I really appreciate not only your patience, but your incredible script wizardry. But I must humbly again request assistance :headshake:  

Do I need to use any script calls? or should I just be able to click the event and have it run? I am not getting it to run on "Event TOuch" or "player touch", and I am not sure entirely what I am doing wrong....
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
Man i feel dense, and I really appreciate not only your patience, but your incredible script wizardry. But I must humbly again request assistance :headshake:

Do I need to use any script calls? or should I just be able to click the event and have it run? I am not getting it to run on "Event TOuch" or "player touch", and I am not sure entirely what I am doing wrong....
Ah, I had only checked for action button events. I already updated the code in the previous post to look for touch events too :)
 

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Huzzzah! You are a genius! I can't tell you how much I not only appreciate this script, but how much use it will see from just me alone! :) ) THANK YOU SO MUCH!
 

Jonini

Villager
Member
Joined
Oct 23, 2018
Messages
20
Reaction score
0
First Language
Russian
Primarily Uses
RMMV
Ah, I had only checked for action button events. I already updated the code in the previous post to look for touch events too :)
I also need this plugin, since I have the same problem:), but the link is not active.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
It got a bit messed up on an old forum transition, but I fixed it now.
 

Jonini

Villager
Member
Joined
Oct 23, 2018
Messages
20
Reaction score
0
First Language
Russian
Primarily Uses
RMMV
It got a bit messed up on an old forum transition, but I fixed it now.
Thanks, but how to manage, for example, I want your plugin to be activated when activating the script \ plugin command.
 

Jonini

Villager
Member
Joined
Oct 23, 2018
Messages
20
Reaction score
0
First Language
Russian
Primarily Uses
RMMV
It got a bit messed up on an old forum transition, but I fixed it now.
I also saw a plugin for you, and didn’t know how to launch it either, so I want to know how? Through the command plugin \ script.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
First Language
Dutch
Primarily Uses
RMXP

Jonini, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.


Since the topic's original request was solved, I'm closing this. Please start a new thread with your questions/problems with Hudell's plugin in Plugin Support.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top